Build Pyinstaller与PIL。导入错误:无法导入名称\u图像

Build Pyinstaller与PIL。导入错误:无法导入名称\u图像,build,python-imaging-library,pyinstaller,pillow,Build,Python Imaging Library,Pyinstaller,Pillow,我在运行包含pillow的已编译可执行文件时遇到问题。我使用了pyinstaller,它似乎编译得足够好,但是在运行exe之后,会抛出一个错误。似乎与引用的是“图像”而不是“图像”存在冲突 首先,我发现pillow是如何安装到PIL目录而不是pillow的,并且模块也被称为PIL。不过,我怀疑这与问题有关 然而,Python27\Lib\site packages\PIL中实际上没有_imaging.py文件,我怀疑这可能是一个问题,因为pyinstaller让可执行文件需要它。不确定是否有某种

我在运行包含pillow的已编译可执行文件时遇到问题。我使用了pyinstaller,它似乎编译得足够好,但是在运行exe之后,会抛出一个错误。似乎与引用的是“图像”而不是“图像”存在冲突

首先,我发现pillow是如何安装到PIL目录而不是pillow的,并且模块也被称为PIL。不过,我怀疑这与问题有关

然而,Python27\Lib\site packages\PIL中实际上没有_imaging.py文件,我怀疑这可能是一个问题,因为pyinstaller让可执行文件需要它。不确定是否有某种方法将其从构建中排除。这可能是下一步

诸如和之类的问题已经提出,但尚未解决。有些人还提到在安装pillow之前没有卸载PIL,但PIL肯定是卸载的,我已经尝试了pillow的二进制文件和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
下面是我如何从我的脚本中调用枕头:

from PIL import Image

您使用的是最新的PyInstaller版本吗?在PyInstaller安装目录下是否有文件
hooks/hook-PIL.Image.py
?是的,PyInstaller v 2.1我有hooks/hook-PIL.Image.py。它看起来空得令人怀疑。除了注释之外,它只包含一行代码:from PyInstaller.hooks.shared_PIL_Image import*尝试将其内容更新为。不幸的是,这不起作用,并导致与上面相同的错误。还有其他建议吗?我似乎有最新版本的pyinstaller。我觉得这是一个相当简单的图像和枕头之间的不匹配。但我不能完全确定。那似乎也不起作用。然而,在卸载枕头和安装PIL之后,这个问题似乎已经解决了。
from PIL import Image