Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
命令提示符中的Python matplotlib importError,而不是Python shell中的Python matplotlib importError_Python_Shell_Import_Matplotlib_Command Prompt - Fatal编程技术网

命令提示符中的Python matplotlib importError,而不是Python shell中的Python matplotlib importError

命令提示符中的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 在命令提示符下运行此脚本

免责声明:我不熟悉python和first post,因此如果这篇文章的格式不正确,或者在网站上的某个地方,我深表歉意。到目前为止,我还没有发现任何东西

我在Win7(64位)上使用python2.7(32位),并尝试使用matplotlib生成简单的绘图。我已经安装了numpy、scipy和matplotlib。matplotlib安装为32位

我有一个脚本('different.py'),它只有一行:

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
它运行并返回

据我所知,它从shell中导入了库,但在命令提示符中出现了问题,我不知道为什么。我看到的唯一一篇相关帖子说,它在导入interactive名称时遇到了问题,因为用户将他们的脚本命名为“new”。我本来就有这个脚本,但将脚本保存为“different.py”,认为它可以解决这个问题,但它没有


知道为什么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