Skip to main content
 首页 » 编程设计

Python pip 安装异常matplotlib

2024年10月24日7pengyingh

操作系统:OSX 10.11.3。

我已经安装了 Python:2.7.10 和 3.4.2。

执行命令:pip install matplotlib

pip 安装日志

pip install matplotlib Downloading/unpacking matplotlib Downloading matplotlib-1.5.1.tar.gz (54.0MB): 54.0MB downloaded Running setup.py (path:/private/var/folders/x1/prmwnk854tj25kslmzb10l5h0000gn/T/pip_build_calebebrim/matplotlib/setup.py) egg_info for package matplotlib ============================================================================ Edit setup.cfg to change the build options

BUILDING MATPLOTLIB 
            matplotlib: yes [1.5.1] 
                python: yes [2.7.8 (default, Oct 19 2014, 16:06:28)  [GCC 
                        4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]] 
              platform: yes [darwin] 
 
REQUIRED DEPENDENCIES AND EXTENSIONS 
                 numpy: yes [version 1.10.4] 
              dateutil: yes [dateutil was not found. It is required for date 
                        axis support. pip/easy_install may attempt to 
                        install it after matplotlib.] 
                  pytz: yes [pytz was not found. pip will attempt to install 
                        it after matplotlib.] 
                cycler: yes [cycler was not found. pip will attempt to 
                        install it after matplotlib.] 
               tornado: yes [using tornado version 4.3] 
             pyparsing: yes [pyparsing was not found. It is required for 
                        mathtext support. pip/easy_install may attempt to 
                        install it after matplotlib.] 
                libagg: yes [pkg-config information for 'libagg' could not 
                        be found. Using local copy.] 
              freetype: no  [The C/C++ header for freetype2 (ft2build.h) 
                        could not be found.  You may need to install the 
                        development package.] 
                   png: yes [version 1.5.23] 
                 qhull: yes [pkg-config information for 'qhull' could not be 
                        found. Using local copy.] 
 
OPTIONAL SUBPACKAGES 
           sample_data: yes [installing] 
              toolkits: yes [installing] 
                 tests: yes [nose 0.11.1 or later is required to run the 
                        matplotlib test suite. Please install it with pip or 
                        your preferred tool to run the test suite / mock is 
                        required to run the matplotlib test suite. Please 
                        install it with pip or your preferred tool to run 
                        the test suite] 
        toolkits_tests: yes [nose 0.11.1 or later is required to run the 
                        matplotlib test suite. Please install it with pip or 
                        your preferred tool to run the test suite / mock is 
                        required to run the matplotlib test suite. Please 
                        install it with pip or your preferred tool to run 
                        the test suite] 
 
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, version 81008] 
                 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: no 
           ghostscript: yes [version 9.10] 
                 latex: no 
               pdftops: no 
 
OPTIONAL PACKAGE DATA 
                  dlls: no  [skipping due to configuration] 
 
============================================================================ 
                        * The following required packages can not be built: 
                        * freetype 
Complete output from command python setup.py egg_info: 
============================================================================ 

Edit setup.cfg to change the build options

BUILDING MATPLOTLIB

        matplotlib: yes [1.5.1] 
 
            python: yes [2.7.8 (default, Oct 19 2014, 16:06:28)  [GCC 
 
                    4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]] 
 
          platform: yes [darwin] 

REQUIRED DEPENDENCIES AND EXTENSIONS

             numpy: yes [version 1.10.4] 
 
          dateutil: yes [dateutil was not found. It is required for date 
 
                    axis support. pip/easy_install may attempt to 
 
                    install it after matplotlib.] 
 
              pytz: yes [pytz was not found. pip will attempt to install 
 
                    it after matplotlib.] 
 
            cycler: yes [cycler was not found. pip will attempt to 
 
                    install it after matplotlib.] 
 
           tornado: yes [using tornado version 4.3] 
 
         pyparsing: yes [pyparsing was not found. It is required for 
 
                    mathtext support. pip/easy_install may attempt to 
 
                    install it after matplotlib.] 
 
            libagg: yes [pkg-config information for 'libagg' could not 
 
                    be found. Using local copy.] 
 
          freetype: no  [The C/C++ header for freetype2 (ft2build.h) 
 
                    could not be found.  You may need to install the 
 
                    development package.] 
 
               png: yes [version 1.5.23] 
 
             qhull: yes [pkg-config information for 'qhull' could not be 
 
                    found. Using local copy.] 

OPTIONAL SUBPACKAGES

       sample_data: yes [installing] 
 
          toolkits: yes [installing] 
 
             tests: yes [nose 0.11.1 or later is required to run the 
 
                    matplotlib test suite. Please install it with pip or 
 
                    your preferred tool to run the test suite / mock is 
 
                    required to run the matplotlib test suite. Please 
 
                    install it with pip or your preferred tool to run 
 
                    the test suite] 
 
    toolkits_tests: yes [nose 0.11.1 or later is required to run the 
 
                    matplotlib test suite. Please install it with pip or 
 
                    your preferred tool to run the test suite / mock is 
 
                    required to run the matplotlib test suite. Please 
 
                    install it with pip or your preferred tool to run 
 
                    the test suite] 

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, version 81008] 
 
             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: no 
 
       ghostscript: yes [version 9.10] 
 
             latex: no 
 
           pdftops: no 

OPTIONAL PACKAGE DATA

              dlls: no  [skipping due to configuration] 

============================================================================

                    * The following required packages can not be built: 
 
                    * freetype 

Removing temporary dir /private/var/folders/x1/prmwnk854tj25kslmzb10l5h0000gn/T/pip_build_calebebrim... Command python setup.py egg_info failed with error code 1 in /private/var/folders/x1/prmwnk854tj25kslmzb10l5h0000gn/T/pip_build_calebebrim/matplotlib Exception information: Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main status = self.run(options, args) File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-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/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-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/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-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/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-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 /private/var/folders/x1/prmwnk854tj25kslmzb10l5h0000gn/T/pip_build_calebebrim/matplotlib

这个是为了:sudo pip install matplotlib

Cleaning up... Removing temporary dir /private/tmp/pip_build_root... Command python setup.py egg_info failed with error code 1 in /private/tmp/pip_build_root/matplotlib Exception information: Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main status = self.run(options, args) File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-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/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-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/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-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/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-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 /private/tmp/pip_build_root/matplotlib

我该怎么办?

我发现了这个: https://github.com/matplotlib/matplotlib/issues/3029/ 它说执行 sudo apt-get pkg-config 或在 osx 上执行 brew install pkg-config 应该可以解决所有问题。

但是执行 brew install pkgconfig 我得到了这个:

Warning: pkg-config-0.28 already installed

请您参考如下方法:

在Mac上使用pip时需要使用sudo,否则pip无法正常访问需要的文件夹特权。所以,把 sudo 放在你的命令之前:

sudo pip install matplotlib 

您还需要输入您的管理员密码,然后它就会安装。