&引用;ImportError:无法导入名称“U imaging”;使用PyInstaller(Python 2)后

&引用;ImportError:无法导入名称“U imaging”;使用PyInstaller(Python 2)后,python,tkinter,python-imaging-library,pyinstaller,Python,Tkinter,Python Imaging Library,Pyinstaller,我用Python 2编写的代码在从Python运行时运行良好,但在我通过PyInstaller发送脚本并运行可执行文件后,它会吐出: Traceback (most recent call last): File "<string>", line 26, in <module> File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, i

我用Python 2编写的代码在从Python运行时运行良好,但在我通过PyInstaller发送脚本并运行可执行文件后,它会吐出:

Traceback (most recent call last):
  File "<string>", line 26, in <module>
  File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "/home/ben/Documents/Programming/Python/Weasyl/Test Scripts/build/test3/out00-PYZ.pyz/PIL.PngImagePlugin", line 40, in <module>
  File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "/home/ben/Documents/Programming/Python/Weasyl/Test Scripts/build/test3/out00-PYZ.pyz/PIL.Image", line 53, in <module>
ImportError: cannot import name _imaging
我假设问题出在PIL import ImageTk的
,Image
,但无法使用该模块,因为我要使用的图像是PNG格式的,据我所知,Tkinter只支持使用该模块之外的GIF格式


编辑:如果我无法将此模块与PyInstaller一起使用,是否有办法使PNG图像在该模块之外的Tkinter中显示?

我遇到了类似的问题。PIL模块成像不工作,尽管PyInstaller似乎没有抱怨。 然而,这只发生在我更新到LinuxMint17之后。以前使用过Mint 15,程序在那里编译并运行良好

我想我会尝试一个旧版本的PIL或其他加载纹理的方法

更新: 好,好消息! 这个问题似乎已经在PyInstaller的当前开发版本中修复。可在此下载:

我还尝试将所有纹理代码改为使用PyGame而不是PIL(因为我在程序中使用了它),但是在使用PyInstaller 2.1生成可执行文件后,运行PyGame也遇到了问题


然而,在GitHub的PyInstaller的当前开发版本中,PyGame和PIL都可以正常工作

这并不能真正回答问题。如果您有不同的问题,可以单击以提问。一旦你有足够的时间,你也可以把更多的注意力放在这个问题上。@Hasturkun-我不认为这是在问另一个问题。他提到有一个类似的问题,但后来用不同的版本来解决。我认为删除这篇文章的最好理由是因为它更多的是旁白或评论,而不是对这个问题的回答。@ArtOfWarfare:这不是答案。它应该是一个评论或一个单独的问题。我刚刚为这个案例选择了最接近的股票评论。好的,我现在已经设法让我的程序工作并更新了帖子。:)@XArgon如何安装开发版本?
#!/usr/bin/env python

from Tkinter import *
from PIL import ImageTk, Image
import os

root = Tk()
name = Label(root, text="(username)", font="Arial 20")
name.grid(row=0, column=0)
status = Label(root, text="(login status)")
status.grid(row=1, column=0)
img = ImageTk.PhotoImage(Image.open(".avatar.png"))
panel = Label(root, image=img, relief=RAISED, height=100, width=100)
panel.grid(row=0, column=1, columnspan=2, rowspan=2)
root.mainloop()