Python ImportError:没有名为matplotlib的模块

Python ImportError:没有名为matplotlib的模块,python,matplotlib,Python,Matplotlib,几个月前Matplotlib工作得很好。但现在我不断地得到错误: ImportError: No module named matplotlib 我再次使用pip安装了matplotlib。它不起作用。我用easyinstall。仍然不起作用 pip安装提供 Requirement already satisfied (use --upgrade to upgrade): matplotlib in /Library/Frameworks/Python.framework/Versions/2

几个月前Matplotlib工作得很好。但现在我不断地得到错误:

ImportError: No module named matplotlib
我再次使用pip安装了matplotlib。它不起作用。我用easyinstall。仍然不起作用

pip安装提供

Requirement already satisfied (use --upgrade to upgrade): matplotlib in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0-py2.7-macosx-10.6-intel.egg
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/python_dateutil-2.4.2-py2.7.egg (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pytz in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pytz-2015.7-py2.7.egg (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): cycler in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cycler-0.9.0-py2.7.egg (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pyparsing!=2.0.0,!=2.0.4,>=1.5.6 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyparsing-2.0.6-py2.7.egg (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/six-1.10.0-py2.7.egg (from python-dateutil->matplotlib)
然后我用

sudo -E pip install matplotlib --upgrade
在那之后我

The directory '/Users/ruskin/Library/Logs/pip' or its parent directory is not owned by the current user and the debug log has been disabled.        Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/ruskin/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled.   Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 6.1.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The directory '/Users/ruskin/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
它继续升级matplotlib,但最终我得到了

Requirement already up-to-date: python-dateutil in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/python_dateutil-2.4.2-py2.7.egg (from matplotlib)
Requirement already up-to-date: pytz in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pytz-2015.7-py2.7.egg (from matplotlib)
Requirement already up-to-date: cycler in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cycler-0.9.0-py2.7.egg (from matplotlib)
Requirement already up-to-date: pyparsing!=2.0.0,!=2.0.4,>=1.5.6 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyparsing-2.0.6-py2.7.egg (from matplotlib)
Requirement already up-to-date: six>=1.5 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/six-1.10.0-py2.7.egg (from python-dateutil->matplotlib)
Installing collected packages: numpy
  Found existing installation: numpy 1.9.1
 Uninstalling numpy-1.9.1:
  Exception:
  Traceback (most recent call last):
    File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 246, in main
      status = self.run(options, args)
    File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 352, in run
      root=options.root_path,
    File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 687, in install
      requirement.uninstall(auto_confirm=True)
    File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 730, in uninstall
      paths_to_remove.remove(auto_confirm)
    File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 126, in remove
      renames(path, new_path)
    File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 292, in renames
      shutil.move(old, new)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 303, in move
      os.unlink(src)
  OSError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy-1.9.1.dist-info/DESCRIPTION.rst'

在OSX上,永远不要将python模块安装为root,这是一个永远失败的快速方法

pip
使用
--user
参数,以便仅为当前用户安装模块,如:

localhost:~ sorins$ which python
/usr/local/bin/python

python -m pip install --user --upgrade matplotlib

另外,请确保您使用的是正确的python解释器,因为pip经常会感到困惑,并在python路径(sys.PATH)中未包含的位置安装模块.

检查您的
python路径。请显示
pip列表的输出
阅读此问题的答案:@TomaszJakubRup matplotlib(1.3.1)在pip中可用list@JasonEstibeiro/Library/Frameworks/Python.framework/Versions/2.7/bin/Python我认为这是解决这个问题的完美方案!花1个多小时来解决这个问题,直到我最终在你的帮助下解决了这个问题。