我当时使用python和matplotlib,但是我的脚本崩溃了,所以我不得不关闭终端(Ubuntu 12.04,matplotib-1.1.0,python2.7)。现在,如果我尝试运行任何脚本,它都会崩溃
import matplotlib.pyplot as plt
有以下错误
Traceback (most recent call last): File "new.py", line 4, in <module> import matplotlib.pyplot as plt File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/__init__.py", line 151, in <module> from matplotlib.rcsetup import (defaultParams, File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/rcsetup.py", line 20, in <module> from matplotlib.colors import is_color_like File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/colors.py", line 54, in <module> import matplotlib.cbook as cbook File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/cbook.py", line 32, in <module> import new File "/home/federico/Documents/doc_uni/idraulica_ambientale/relazione/scripts/variabili/new.py", line 4, in <module> import matplotlib.pyplot as plt File "/usr/local/lib/python2.7/dist-packages/matplotlib-1.2.0-py2.7-linux-i686.egg/matplotlib/pyplot.py", line 23, in <module> from matplotlib import _pylab_helpers, interactive ImportError: cannot import name interactive
注意最后一行。我尝试从源代码以及pip和easy_install中删除并重新安装matplotlib,但是我无法摆脱。如果我尝试从python解释器中导入,则会发生相同的错误。我还安装了1.2.0版,以查看是否可以运行,但不能。
如果您仔细阅读了堆栈跟踪中的文件,
new.py-> /matplotlib/__init__.py-> matplotlib/rcsetup.py,/matplotlib/colors.py-> /matplotlib/cbook.py-> / home/federico/Documents/../new.py- >matplotlib/pyplot.py
new.py
/matplotlib/__init__.py
matplotlib/rcsetup.py
/matplotlib/colors.py
/matplotlib/cbook.py
matplotlib/pyplot.py
您已经命名自己的模块,new这与进口阴影matplolib.cbook,这是造成你尝试imortpyplot要导入,而pyplot其中aparently炸毁(究竟 为什么 是我上面的paygrade)。您只需要将模块重命名为其他名称即可new.py(并记住删除new.pyc创建的文件)。
new
matplolib.cbook
pyplot
new.pyc
作为import matplotlib.pyplot as plt在交互式外壳中运行的测试。
仅供参考,这就是您要隐藏的内容。
导入将在mpl 1.3中删除