ubuntu 14.04,pip无法升级matplotllib

时间:2014-09-04 20:38:33

标签: python matplotlib pip

当我尝试使用pip升级matplotlib时,它会输出:

Downloading/unpacking matplotlib from https://pypi.python.org/packages/source/m/matplotlib/matplotlib-1.4.0.tar.gz#md5=1daf7f2123d94745feac1a30b210940c
  Downloading matplotlib-1.4.0.tar.gz (51.2MB): 51.2MB downloaded
  Running setup.py (path:/tmp/pip_build_root/matplotlib/setup.py) egg_info for package matplotlib
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.4.0]
                    python: yes [2.7.6 (default, Mar 22 2014, 22:59:38)  [GCC
                            4.8.2]]
                  platform: yes [linux2]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.8.2]
                       six: yes [using six version 1.7.3]
                  dateutil: yes [using dateutil version 2.2]
                   tornado: yes [using tornado version 4.0.1]
                 pyparsing: yes [using pyparsing version 2.0.2]
                     pycxx: yes [Couldn't import.  Using local copy.]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/matplotlib/setup.py", line 154, in <module>
        result = package.check()
      File "setupext.py", line 940, in check
        if 'No such file or directory\ngrep:' in version:
    TypeError: argument of type 'NoneType' is not iterable
    Complete output from command python setup.py egg_info:
    ============================================================================

Edit setup.cfg to change the build options



BUILDING MATPLOTLIB

            matplotlib: yes [1.4.0]

                python: yes [2.7.6 (default, Mar 22 2014, 22:59:38)  [GCC

                        4.8.2]]

              platform: yes [linux2]



REQUIRED DEPENDENCIES AND EXTENSIONS

                 numpy: yes [version 1.8.2]

                   six: yes [using six version 1.7.3]

              dateutil: yes [using dateutil version 2.2]

               tornado: yes [using tornado version 4.0.1]

             pyparsing: yes [using pyparsing version 2.0.2]

                 pycxx: yes [Couldn't import.  Using local copy.]

                libagg: yes [pkg-config information for 'libagg' could not

                        be found. Using local copy.]

Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/matplotlib/setup.py", line 154, in <module>

    result = package.check()

  File "setupext.py", line 940, in check

    if 'No such file or directory\ngrep:' in version:

TypeError: argument of type 'NoneType' is not iterable

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib
Storing debug log for failure in /home/username/.pip/pip.log

在日志的尾部,它说:

Exception information:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1229, in prepare_files
    req_to_install.run_egg_info()
  File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 325, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib

为什么会失败? 非常感谢!

9 个答案:

答案 0 :(得分:74)

这是已修复(https://github.com/matplotlib/matplotlib/pull/3414)master上的已知错误。

该错误在于处理搜索freetype安装。如果您安装Linux软件包freetype-dev,您将避免此错误并能够编译matplotlib

sudo apt-get install libfreetype6-dev

答案 1 :(得分:68)

在Ubuntu 14服务器上,您还需要安装libxft-dev

sudo apt-get install libfreetype6-dev libxft-dev

答案 2 :(得分:12)

我在尝试使用matplotlib在Python 3上安装pip3时遇到了同样的问题,似乎这个问题与Python 3的简单安装有关,并且做了:

sudo apt-get build-dep matplotlib

接着是

sudo pip3 install matplotlib 

可能是比仅选择性地安装与matplotlib相关的库的更好的解决方案。

答案 3 :(得分:3)

由于mac没有apt-get you,在OSX上你可能需要这样做:

brew install freetype

然后你可以运行:

pip install matplotlib

答案 4 :(得分:1)

在寻找Fedora 24的答案时找到此页面。

RPM解决方案是:

dnf install freetype-devel

答案 5 :(得分:1)

如果你重新运行Ubuntu服务器14.04,你应该添加这个字体依赖

sudo apt-get install libxft-dev

Source

答案 6 :(得分:0)

我尝试使用sudo pip直接更新,但最后没有保存更改。所以我首先在终端中使用update cmd:

git tag -d `git tag | grep -E '^*\._test$'`

然后我使用了sudo install:

sudo apt-get update

最后通过这种方法安装它。

答案 7 :(得分:0)

对于那些使用Fedora 25的人来说,我需要这两个软件包才能使它工作:

sudo dnf install freetype-devel gcc-c++

答案 8 :(得分:0)

这对我有用:

python -m pip install -U pip setuptools
python -m pip install matplotlib

有关更多详细信息,请遵循:https://matplotlib.org/2.0.0/users/installing.html