Python 在Ubuntu上安装matplotlib:ImportError

Python 在Ubuntu上安装matplotlib:ImportError,python,matplotlib,importerror,Python,Matplotlib,Importerror,我的平台: Ubuntu 13.04,Python 2.7.4 安装matplotlib失败,ImportError:没有名为pyplot的模块 我试过很多方法,比如 $ sudo apt-get install python-matplotlib 简单安装,从源代码安装…,我正在跟进 但它们都不起作用,这种恐怖总是发生,有人能帮忙吗 编辑追溯: --------------------------------------------------------------------------

我的平台:

Ubuntu 13.04,Python 2.7.4

安装matplotlib失败,ImportError:没有名为pyplot的模块

我试过很多方法,比如

$ sudo apt-get install python-matplotlib
简单安装,从源代码安装…,我正在跟进

但它们都不起作用,这种恐怖总是发生,有人能帮忙吗

编辑追溯:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-82be63b7783c> in <module>()
----> 1 import matplotlib

/home/wuhuijia/matplotlib.py in <module>()
      1 import numpy as np
----> 2 import matplotlib.pyplot as plt
      3 import scipy.optimize as so
      4 
      5 def find_confidence_interval(x, pdf, confidence_level):

ImportError: No module named pyplot
---------------------------------------------------------------------------
ImportError回溯(最近一次呼叫最后一次)
在()
---->1导入matplotlib
/home/wuhuijia/matplotlib.py in()
1作为np导入numpy
---->2将matplotlib.pyplot作为plt导入
3导入scipy.optimize以便
4.
5 def查找置信区间(x,pdf,置信水平):
ImportError:没有名为pyplot的模块

您的脚本名为
matplotlib.py
。Python在导入模块时将首先查看本地,即目录本身。因此,在执行
import matplotlib.pyplot
时,Python将导入脚本(而不是已安装的matplotlib),并且由于脚本没有子模块
pyplot
,因此将失败


将您的脚本重命名为其他脚本(例如,
testmpl.py
),您应该会没事的。

您可以向我们展示导入错误的跟踪信息吗?我没有得到这个。。。我也有同样的问题。。你能详细描述一下吗?为什么重命名脚本可以解决这个问题?我不清楚