我编写了一个使用以下技术的Python应用程序:
from PIL import Image
我想发布一个打包版本的应用程序,这样使用它的人就不需要安装所有的依赖项。为此,我使用了pyinstaller,但效果不太好。我运行了以下命令:pyinstaller --onefile image_download.py,没有报错。然而,当我运行应用程序时,出现以下错误信息:Traceback (most recent call last):File "", line 26, in File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_moduleexec(bytecode, module.dict)File "/home/ic/twitter-project/build/image_download/out00-PYZ.pyz/PIL.PngImagePlugin", line 40, in File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_moduleexec(bytecode, module.dict)File "/home/ic/twitter-project/build/image_download/out00-PYZ.pyz/PIL.Image", line 63, in ImportError: cannot import name _imaging。我正在使用Ubuntu 14.04、Python 2.7、pyinstaller 2.1和PIL.VERSION 1.1.7(尽管我认为我已经安装了Pillow 2.8.1)。脚本作为python image_download.py正常运行,但是由于某些原因,pyinstaller无法导入_imaging。有什么建议吗?
import _imaging
添加到image_download.py的顶部并重新构建可执行文件……有时会错过奇怪的隐藏导入,它可能像import("_imaging")
这样在某个地方导入。 - Joran Beasleyimport PIL._imaging
和其他几个组合,但都没有成功。 - user2891462