Py2app fails with scrapy

◇◆丶佛笑我妖孽 提交于 2019-12-11 19:02:10

问题


If been trying to create a standalone version of my project. I've been able to create the setup file and the alias app with py2app with no problems. Running the alias app works without problems. However, when creating the independent file the app does not run any more.

First of all the error i receive upon opening the app is as follows:

File "scrapy/__init__.pyc", line 10, in <module>
File "pkgutil.pyc", line 616, in get_data
File "importlib/util.pyc", line 83, in find_spec
AttributeError: 'NoneType' object has no attribute 'startswith'

As the first line points to the scrapy module i tried to recreate the problem with an empty project.

As expected the empty project works flawless. The app runs independently without any errors. Until adding the scrapy framework. I made this little script trying to recreate the problem:

import scrapy

if __name__ == '__main__':
    scrapy.Request("http://www.google.com")

With this file i tried to create the independent app again, and as expected it crashes with the same error as above.

Any help regarding this problem will be greatly appreciated.

UPDATE

As suggested by user5214530, I have tried to create the standalone app with pyinstaller and the --onefile command. Sadly, I did get similar results as before.

File "site-packages/scrapy/__init__.py", line 10, in <module>
File "pkgutil.py", line 634, in get_data
File "/Users/.../Test/venv/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 479, in get_data
with open(path, 'rb') as fp:
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/mz/rg4w2jjj2zj5rtvnv8lxby2w0000gn/T/_MEIiGJyET/scrapy/VERSION'

As you may see I tried this with the simple test script with only scrapy in it and it also fails. May it be a problem with scrapy?


回答1:


I would suggest you use pyinstaller instead, with --onefile command.

1.) pip install pyinstaller
2.) pyinstaller --onefile script.py



来源:https://stackoverflow.com/questions/50841317/py2app-fails-with-scrapy

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