简体   繁体   English

Py2app失败并刮擦

[英]Py2app fails with scrapy

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. 我已经能够使用py2app创建安装文件和别名应用程序,而没有任何问题。 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. 第一行指向scrapy模块时,我试图用一个空项目来重新创建问题。

As expected the empty project works flawless. 正如预期的那样,空项目工作正常。 The app runs independently without any errors. 该应用程序独立运行,没有任何错误。 Until adding the scrapy framework. 直到添加了scrapy框架。 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. 如user5214530所建议,我尝试使用pyinstaller和--onefile命令创建独立应用程序。 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? 刮y可能有问题吗?

I would suggest you use pyinstaller instead, with --onefile command. 我建议您使用--onefile命令代替pyinstaller。

1.) pip install pyinstaller 1.)pip install py安装程序
2.) pyinstaller --onefile script.py 2.)pyinstaller --onefile script.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM