难以在Mac OS上更新matplotlib

时间:2017-06-28 20:05:40

标签: python matplotlib pip

编辑:修正。解决方法是安装anaconda并通过它运行python。

我在Mac上运行Sierra 10.12.5,pip list | grep matplotlib表明我正在运行matplotlib(1.3.1)。我正在尝试将matplotlib更新为2.0.2(最新版本),但是任何sudo pip install matplotlib --upgrade似乎都会失败,并且会出现非常长的错误(不会将其全部粘贴到此处):

Terrys-MBP:Bitcore-master-2 Terry$ pip install matplotlib --upgrade
Downloading/unpacking matplotlib from https://pypi.python.org/packages/f5/f0/9da3ef24ea7eb0ccd12430a261b66eca36b924aeef06e17147f9f9d7d310/matplotlib-2.0.2.tar.gz#md5=061111784278bde89b5d4987014be4ca
Downloading matplotlib-2.0.2.tar.gz (53.9MB): 53.9MB downloaded
Running setup.py      (path:/private/var/folders/m5/1fg5rnj11_9cz5pntlqlwzyc0000gn/T/pip_build_Terry/matplotlib/setup.py) egg_info for package matplotlib
============================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
            matplotlib: yes [2.0.2]
                python: yes [2.7.10 (default, Feb  7 2017, 00:08:15)  [GCC
                        4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]]
              platform: yes [darwin]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.13.0]
                   six: yes [using six version 1.10.0]
              dateutil: yes [using dateutil version 2.6.0]
           functools32: yes [using functools32]
          subprocess32: yes [using subprocess32]
                  pytz: yes [using pytz version 2017.2]
                cycler: yes [using cycler version 0.10.0]
               tornado: yes [using tornado version 4.5.1]
             pyparsing: yes [using pyparsing version 2.2.0]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: yes [version 2.8.0]
                   png: yes [version 1.6.29]
                 qhull: yes [pkg-config information for 'qhull' could not be
                        found. Using local copy.]

OPTIONAL SUBPACKAGES
           sample_data: yes [installing]
              toolkits: yes [installing]
                 tests: no  [skipping due to configuration]
        toolkits_tests: no  [skipping due to configuration]

OPTIONAL BACKEND EXTENSIONS
                macosx: yes [installing, darwin]
                qt5agg: no  [PyQt5 not found]
                qt4agg: no  [PySide not found; PyQt4 not found]
               gtk3agg: no  [Requires pygobject to be installed.]
             gtk3cairo: no  [Requires cairocffi or pycairo to be installed.]
                gtkagg: no  [Requires pygtk]
                 tkagg: yes [installing; run-time loading from Python Tcl /
                        Tk]
                 wxagg: no  [requires wxPython]
                   gtk: no  [Requires pygtk]
                   agg: yes [installing]
                 cairo: no  [cairocffi or pycairo not found]
             windowing: no  [Microsoft Windows only]

OPTIONAL LATEX DEPENDENCIES
                dvipng: yes [version 1.15]
           ghostscript: yes [version 9.16]
                 latex: yes [version 3.14159265]
               pdftops: no

OPTIONAL PACKAGE DATA
                  dlls: no  [skipping due to configuration]

Requirement already up-to-date: numpy>=1.7.1 in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already up-to-date: six>=1.10 in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already up-to-date: python-dateutil in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already up-to-date: functools32 in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already up-to-date: subprocess32 in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already up-to-date: pytz in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already up-to-date: cycler>=0.10 in /Library/Python/2.7/site-packages (from matplotlib)
Requirement already up-to-date: pyparsing>=1.5.6,!=2.0.4,!=2.1.2,!=2.1.6 in /Library/Python/2.7/site-packages (from matplotlib)
Installing collected packages: matplotlib
Found existing installation: matplotlib 1.3.1
Uninstalling matplotlib:
Cleaning up...
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)

我认为尝试卸载1.3.1有问题,因为当我尝试为matplotlib执行pip uninstall时,会发生完全相同的错误。

之前我有点数版本1.5.6,并通过以下评论的建议更新到9.0.1。它还没有修复问题。

我已经尝试过sudo chown -R $USER /Library/Python/2.7认为这可能是一个权限问题而且我也对brew install pkg-configbrew install freetype进行了混乱无济于事。

有没有人有任何想法如何解决这个问题?

编辑:不,它不是虚拟环境,它在我的Mac终端上,默认安装位置为pip和python。

2 个答案:

答案 0 :(得分:0)

评论太长了,希望无论如何都有帮助。

File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 122, in main行看,Evert是正确的,你的点子本身就更新了(它可能就是系统附带的那个)。输入pip --version进行确认(并将结果复制粘贴到您的问题中)。

如果是这种情况(pip,我建议您通过文件~/.local/bin~/.bash_profile添加到PATH https://en.wikipedia.org/wiki/PATH_%28variable%29环境变量中进行更新2.重新启动终端和3 。问题pip install -U --user pip setuptools。检查which pip是否返回~/.local/bin/pip

然后卸载系统范围内安装的matplotlib(在/Library中使用pip进行安装会导致麻烦)并尝试pip install -U --user matplotlib

答案 1 :(得分:-1)

通过安装anaconda解决。它附带最新版本的matplotlib。我也推荐其他人这样做。