Python 在Mac OS上更新matplotlib有困难

Python 在Mac OS上更新matplotlib有困难,python,matplotlib,pip,Python,Matplotlib,Pip,编辑:修正。通过安装anaconda并运行python解决了这个问题 我在Mac上运行Sierra 10.12.5,而pip list | grep matplotlib显示我正在运行matplotlib(1.3.1)。我正在尝试将matplotlib更新到2.0.2(最新版本),但是任何sudo pip安装matplotlib——升级似乎都失败了,出现了一个非常长的错误(不会全部粘贴到这里),导致: Terrys-MBP:Bitcore-master-2 Terry$ pip install

编辑:修正。通过安装
anaconda
并运行python解决了这个问题

我在Mac上运行Sierra 10.12.5,而
pip list | grep matplotlib
显示我正在运行matplotlib(1.3.1)。我正在尝试将matplotlib更新到2.0.2(最新版本),但是任何
sudo pip安装matplotlib——升级
似乎都失败了,出现了一个非常长的错误(不会全部粘贴到这里),导致:

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卸载时,会发生完全相同的错误

我之前有pip版本1.5.6,刚刚通过下面评论的建议更新到9.0.1。它还没有解决这些问题

我试过
sudo chown-R$USER/Library/Python/2.7
认为这可能是一个权限问题,我也尝试过
brew install pkg config
brew install freetype
但没有成功

有人知道如何解决这个问题吗


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

评论太长了,希望能有所帮助

从主代码第122行的
文件“/Library/Python/2.7/site packages/pip/basecommand.py”中可以看出,Evert是正确的,并且您的pip已经自我更新(可能是系统附带的)。键入
pip--version
进行确认(并将结果复制粘贴到问题中)


如果是这种情况(pip,我建议您通过以下方式进行更新:1.通过文件
~/.bash_profile
向PATH环境变量添加
~/.local/bin
);2.重新启动终端;3.发出
pip安装-U--用户pip设置工具
。检查
哪个pip
返回
~/.local/bin/pip>


然后卸载系统范围内安装的matplotlib(在
/Library
中使用pip安装会导致故障)然后尝试
pip安装-U--用户matplotlib

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

您使用的是虚拟环境吗?尝试VirtualEnvironment以获得一个新的环境不,我目前没有使用虚拟环境,我会看看这个。它是这可能是pip的一个问题,因为它已经足够过时,可以处理进入mpl2的
setup.py
中的新包样式/命令。虽然很难说,但回溯有限。有没有可能在当前行之前再添加几行(不是全部,而是10-20行,这样可以更清楚地显示错误的来源)?好了,更新后包含了我发布的原始错误代码上方的所有行。我检查了我的pip版本,它是1.5.6,我刚刚更新到9.0.1,但尝试更新matplotlib,仍然是相同的错误。我将尝试您上面建议的所有操作,并会回复您,干杯。我刚刚尝试使用pip卸载matplotlib进行卸载,但确实如此似乎对此不满意。给出了与上述完全相同的错误。有更好的安装方法吗?哪个pip的输出是什么?此外,您可能需要(注意,这是您的责任)要进入安装matplotlib的目录,请使用cd/Library/Python/2.7/site packages
并删除matplotlib
rm-r matplotlib*
(注意:matplotlib和星形之间没有空格,请先执行
ls matplotlib*
,然后在终端历史记录中向上一步(向上箭头)并用
rm-r
)替换ls。
哪个pip
返回
/usr/local/bin/pip
pip--version
的输出是什么?