【发布时间】:2018-10-08 07:40:58
【问题描述】:
当我到达我心爱的 Spyder 控制台时,它欢迎我
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
%guiref -> A brief reference about the graphical user interface.
我继续输入:
In [1]: from PIL import Image
然后它会显示另一行,就像一切都正确一样。 然后,在下一行,我输入:
In [2]: from PIL import ImageTk
它返回这个:
Traceback (most recent call last):
File "<ipython-input-2-47edf18ebb7f>", line 1, in <module>
from PIL import ImageTk
ImportError: cannot import name ImageTk
好的,这意味着我的库应该有问题。没有汗水。 一位程序员同事遇到了类似的错误here,并且:
- 我确信我的导入中没有拼写错误
- Ubuntu 报告 python-imaging 包是最新的:
- Ubuntu 在 python-imaging-tk 包中报告以下内容:
这些 Bash 行:
python-imaging is already the newest version (3.1.2-0ubuntu1.1).
<more bash lines />
The following packages have unmet dependencies:
python-imaging-tk : Depends: python-imaging (= 1.1.7-4) but 3.1.2-0ubuntu1.1 is to be installed
这是最有趣的部分。当我返回 Spyder 并键入以获取 PIL.Image 的版本时,它会返回:
In [3]: Image.VERSION
Out[3]: '1.1.7'
我在这里不知所措。请发送帮助。
【问题讨论】:
标签: python-2.7 ipython python-imaging-library python-import importerror