Python 运行pyinstaller应用程序时出现导入错误
我编写了一个Python应用程序,它利用了:Python 运行pyinstaller应用程序时出现导入错误,python,pyinstaller,pillow,Python,Pyinstaller,Pillow,我编写了一个Python应用程序,它利用了: from PIL import Image 我想分发这个应用程序的打包版本,这样使用它的人就不需要安装所有依赖项 为此,我使用了pyinstaller,但没有太大成功。 我运行: pyinstaller--onefile image_download.py 它也没有抱怨。但是,当我运行应用程序时,我得到: 回溯(最近一次呼叫最后一次): 文件“”,第26行,在 文件“/usr/local/lib/python2.7/dist packages/Py
from PIL import Image
我想分发这个应用程序的打包版本,这样使用它的人就不需要安装所有依赖项
为此,我使用了pyinstaller
,但没有太大成功。
我运行:
pyinstaller--onefile image_download.py
它也没有抱怨。但是,当我运行应用程序时,我得到:
回溯(最近一次呼叫最后一次):
文件“”,第26行,在
文件“/usr/local/lib/python2.7/dist packages/PyInstaller/loader/pyi_importers.py”,第270行,在load_模块中
exec(字节码,模块.dict)
文件“/home/ic/twitter project/build/image_download/out00 PYZ.PYZ/PIL.PngImagePlugin”,第40行,在
文件“/usr/local/lib/python2.7/dist packages/PyInstaller/loader/pyi_importers.py”,第270行,在load_模块中
exec(字节码,模块.dict)
文件“/home/ic/twitter project/build/image_download/out00 PYZ.PYZ/PIL.image”,第63行,在
导入错误:无法导入名称\u图像
我正在使用:
- Ubuntu 14.04
- Python 2.7
- pyinstaller 2.1
- PIL.Version1.1.7(尽管我以为我已经安装了Pillow 2.8.1)
python image\u download.py
,但由于某些原因,pyinstaller无法导入图像
有什么建议吗?最后,我无法使用
pyinstaller
,因为我无法解决导入问题
尽管如此,我还是设法用
Nuitka
和bbfreeze
构建了一个独立的可执行文件,以防任何人遇到同样的问题:值得尝试其他工具。尝试将import\u imaging
添加到image\u download.py的顶部,并重新构建可执行文件。。。有时,它会错过奇怪的隐藏导入,可能是像导入(“\u imaging”)之类的导入,或者是一些没有运气的东西,没有这样的导入。我尝试了导入PIL.\u图像和其他几种组合,但没有成功。请检查此答案