命令提示符中的Python matplotlib importError,而不是Python shell中的Python matplotlib importError
免责声明:我不熟悉python和first post,因此如果这篇文章的格式不正确,或者在网站上的某个地方,我深表歉意。到目前为止,我还没有发现任何东西 我在Win7(64位)上使用python2.7(32位),并尝试使用matplotlib生成简单的绘图。我已经安装了numpy、scipy和matplotlib。matplotlib安装为32位 我有一个脚本('different.py'),它只有一行:命令提示符中的Python matplotlib importError,而不是Python shell中的Python matplotlib importError,python,shell,import,matplotlib,command-prompt,Python,Shell,Import,Matplotlib,Command Prompt,免责声明:我不熟悉python和first post,因此如果这篇文章的格式不正确,或者在网站上的某个地方,我深表歉意。到目前为止,我还没有发现任何东西 我在Win7(64位)上使用python2.7(32位),并尝试使用matplotlib生成简单的绘图。我已经安装了numpy、scipy和matplotlib。matplotlib安装为32位 我有一个脚本('different.py'),它只有一行: import matplotlib.pyplot as plt 在命令提示符下运行此脚本
import matplotlib.pyplot as plt
在命令提示符下运行此脚本将返回以下错误:
C:\Users\Robert\Desktop>python different.py
Traceback (most recent call last):
File "different.py", line 1, in <module>
import matplotlib as plt
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 165, in <module>
from matplotlib.rcsetup import (defaultParams,
File "C:\Python27\lib\site-packages\matplotlib\rcsetup.py", line 20, in <module>
from matplotlib.colors import is_color_like
File "C:\Python27\lib\site-packages\matplotlib\colors.py", line 54, in <module>
import matplotlib.cbook as cbook
File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 34, in <module>
import new
File "C:\Users\Robert\Desktop\new.py", line 1, in <module>
import matplotlib.pyplot
File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 23, in <module>
from matplotlib import _pylab_helpers, interactive
ImportError: cannot import name interactive
它运行并返回
知道为什么ImportError出现在命令提示符中而不是shell中吗?桌面上仍然有一个名为new.py的文件。在import语句链的某个位置,有一个“import new”,它会找到您的new.py,但一切都出错了:
File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 34, in <module>
import new
File "C:\Users\Robert\Desktop\new.py", line 1, in <module>
import matplotlib.pyplot
文件“C:\Python27\lib\site packages\matplotlib\cbook.py”,第34行,在
引进新产品
文件“C:\Users\Robert\Desktop\new.py”,第1行,在
导入matplotlib.pyplot
请删除或重命名您的new.py以及可能已创建的任何相应的new.pyc,然后重试,或从其他工作目录重试。作为旁注,这将在版本1.3中得到修复。很抱歉这么晚才标记您的答案。我记得我更改了.py名称,但我不知道.pyc。一旦我这样做了,它就运行得非常完美。
File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 34, in <module>
import new
File "C:\Users\Robert\Desktop\new.py", line 1, in <module>
import matplotlib.pyplot