Pyinstaller scrapy error:

落爺英雄遲暮 提交于 2019-12-04 18:53:19

Inside scrapy/__init__.py, you'll see the part where the author uses pkgutil.get_data(). I'm not very sure if you need to indicate to pyinstaller that the scrapy/VERSION text file gets packaged altogether like a data file, or if pkgutil.get_data works at all for pyinstaller, but heres a quick hack I used.

Simply go to the __init__.py file, comment away these 2 lines and replace with a string of your choice e.g __version__="scrap-123". You will need __version__ as it's being referred to in another module.

__version__ = pkgutil.get_data(__package__, 'VERSION').decode('ascii').strip()
version_info = tuple(int(v) if v.isdigit() else v
                     for v in __version__.split('.'))

You need to create a scrapy folder under the same directory as runspider.exe (the exe file generated by pyinstaller).

Then copy the "VERSION" and "mime.types" files(default path: %USERPROFILE%\AppData\Local\Programs\Python\Python37\Lib\site-packages\scrapy) to the scrapy you just created in the scrappy folder you create . (If you only copy "VERSION", you will be prompted to find the "mime.types" file)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!