我无法运行包含枕头的已编译可执行文件。我使用了似乎编译得很好的pyinstaller,但是在运行exe之后,会抛出一个错误。似乎与'_imaging'被引用而不是'Image'存在冲突。
首先,我发现枕头安装到PIL目录而不是枕头是很奇怪的,模块也被称为PIL。我怀疑这与问题有什么关系。
Python27 \ Lib \ site-packages \ PIL中实际上没有_imaging.py文件,但我怀疑这可能是一个问题,因为某种程度上pyinstaller已经让可执行文件需要它。不确定是否有某种方法可以将其从构建中排除。这可能是下一步。
this和this等问题已经提出但尚未解决。有些人还提到PIL没有在安装枕头之前卸载,但PIL肯定是卸载的,我已经尝试了二进制文件和pip安装枕头。
有什么建议吗?
运行时错误:
Traceback (most recent call last):
File "<string>", line 26, in <module>
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\PIL.PngImagePlugin", line 40, in <module>
File "C:\Python27\Lib\site-packages\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\Hp\PycharmProjects\GISdev\build\gis_helper2\out00-PYZ.pyz\PIL.Image", line 63, in <module>
ImportError: cannot import name _imaging
PIL.Image文件的摘录位于下方,违规行为
来自PIL import _imaging as core
try:
# If the _imaging C module is not present, Pillow will not load.
# Note that other modules should not refer to _imaging directly;
# import Image and use the Image.core variable instead.
# Also note that Image.core is not a publicly documented interface,
# and should be considered private and subject to change.
from PIL import _imaging as core
if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
raise ImportError("The _imaging extension was built for another "
" version of Pillow or PIL")
from PIL import Image
这就是我从剧本中称呼枕头的方式:
from PIL import Image