简体   繁体   English

Ubuntu 12.04 LTS VirtualBox VM&Python 2.7.3-'sudo pip install matplotlib'致命错误

[英]Ubuntu 12.04 LTS VirtualBox VM & Python 2.7.3 - 'sudo pip install matplotlib' fatal error

I'm installing various Python libraries onto an Ubuntu Linux 12.04 LTS VirtualBox VM which I recently created from scratch. 我正在将各种Python库安装到我最近从头创建的Ubuntu Linux 12.04 LTS VirtualBox VM上。 This is so I can do some Python-related university work on my own machine. 这样我就可以在自己的计算机上完成一些与Python相关的大学工作。 I was advised in resources given to me by my lecturer to run the following commands to get the packages I need up and running: 我的讲师建议我使用以下命令来运行我的资源,以获取我需要的软件包:

$ sudo apt-get install python-dev python-numpy python-numpy-dev python-setuptools python-numpy-dev python-scipy libatlas-dev g++ python-pip cython python-imaging
$ sudo pip matplotlib scikit-learn scikit-image pybrain PIL

I quickly found the 2nd command had an error in it, and so I changed it to $ sudo pip install matplotlib ... before re-running it. 我很快发现第二个命令中有一个错误,因此在重新运行它之前将其更改为$ sudo pip install matplotlib ...

However, during the re-run, I came across an error where matplotlib could not build because Freetype was not installed. 但是,在重新运行期间,我遇到了一个错误,其中由于未安装Freetype而无法构建matplotlib。 And so I followed this Stackoverflow post " Ubuntu running `pip install` gives error 'The following required packages can not be built: * freetype' " to get the required libfreetype6 package installed on my system. 因此,我遵循了这个Stackoverflow帖子“ Ubuntu运行`pip install`给出错误'无法构建以下必需的软件包:* freetype' “,以在我的系统上安装必需的libfreetype6软件包。

This leads onto my current problem. 这导致了我当前的问题。 My newest attempts to build matplotlib produce an error accompanied with the following wall-of-text 'pip.log' file: 我最近一次尝试构建matplotlib的尝试会产生错误,并伴随以下文本墙“ pip.log”文件:

------------------------------------------------------------
/usr/bin/pip run on Wed Feb 12 14:29:17 2014
Downloading/unpacking matplotlib
  Running setup.py egg_info for package matplotlib
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.3.1]
                    python: yes [2.7.3 (default, Sep 26 2013, 20:08:41)  [GCC
                            4.6.3]]
                  platform: yes [linux2]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.6.1]
                  dateutil: yes [using dateutil version 1.5]
                   tornado: yes [tornado was not found. It is required for the
                            WebAgg backend. pip/easy_install may attempt to
                            install it after matplotlib.]
                 pyparsing: yes [pyparsing was not found. It is required for
                            mathtext support. pip/easy_install may attempt to
                            install it after matplotlib.]
                     pycxx: yes [Couldn't import.  Using local copy.]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
                  freetype: yes [version 14.0.8]
                       png: yes [pkg-config information for 'libpng' could not
                            be found. Using unknown version.]

    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]

    OPTIONAL BACKEND EXTENSIONS
                    macosx: no  [Mac OS-X only]
                    qt4agg: no  [PyQt4 not found]
                   gtk3agg: yes [installing, version 3.2.4]
                 gtk3cairo: yes [installing, version 3.2.4]
                    gtkagg: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                            be found.  You may need to install the development
                            package.]
                     tkagg: no  [The C/C++ header for Tk (tk.h) could not be
                            found.  You may need to install the development
                            package.]
                     wxagg: no  [requires wxPython]
                       gtk: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                            be found.  You may need to install the development
                            package.]
                       agg: yes [installing]
                     cairo: yes [installing, version 1.8.8]
                 windowing: no  [Microsoft Windows only]

    OPTIONAL LATEX DEPENDENCIES
                    dvipng: no
               ghostscript: yes [version 9.05]
                     latex: no
                   pdftops: yes [version 0.18.4]

    running egg_info
    writing requirements to pip-egg-info/matplotlib.egg-info/requires.txt
    writing pip-egg-info/matplotlib.egg-info/PKG-INFO
    writing namespace_packages to pip-egg-info/matplotlib.egg-info/namespace_packages.txt
    writing top-level names to pip-egg-info/matplotlib.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/matplotlib.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/matplotlib.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/matplotlib.egg-info/SOURCES.txt'
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.5 in /usr/lib/python2.7/dist-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/lib/python2.7/dist-packages (from matplotlib)
Downloading/unpacking tornado (from matplotlib)
  Running setup.py egg_info for package tornado
    running egg_info
    writing requirements to pip-egg-info/tornado.egg-info/requires.txt
    writing pip-egg-info/tornado.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/tornado.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/tornado.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/tornado.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/tornado.egg-info/SOURCES.txt'
  Source in ./build/tornado has version 3.2, which satisfies requirement tornado (from matplotlib)
Downloading/unpacking pyparsing>=1.5.6,!=2.0.0 (from matplotlib)
  Running setup.py egg_info for package pyparsing
    running egg_info
    writing pip-egg-info/pyparsing.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/pyparsing.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/pyparsing.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/pyparsing.egg-info/SOURCES.txt'
    writing manifest file 'pip-egg-info/pyparsing.egg-info/SOURCES.txt'
  Source in ./build/pyparsing has version 2.0.1, which satisfies requirement pyparsing>=1.5.6,!=2.0.0 (from matplotlib)
Downloading/unpacking nose (from matplotlib)
  Running setup.py egg_info for package nose
    running egg_info
    writing pip-egg-info/nose.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/nose.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/nose.egg-info/dependency_links.txt
    writing entry points to pip-egg-info/nose.egg-info/entry_points.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/nose.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'doc/.build'
    writing manifest file 'pip-egg-info/nose.egg-info/SOURCES.txt'
  Source in ./build/nose has version 1.3.0, which satisfies requirement nose (from matplotlib)
Downloading/unpacking backports.ssl-match-hostname (from tornado->matplotlib)
  Running setup.py egg_info for package backports.ssl-match-hostname
    running egg_info
    writing pip-egg-info/backports.ssl_match_hostname.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/backports.ssl_match_hostname.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/backports.ssl_match_hostname.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/backports.ssl_match_hostname.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/backports.ssl_match_hostname.egg-info/SOURCES.txt'
  Source in ./build/backports.ssl-match-hostname has version 3.4.0.2, which satisfies requirement backports.ssl-match-hostname (from tornado->matplotlib)
Installing collected packages: matplotlib, tornado, pyparsing, nose, backports.ssl-match-hostname
  Running setup.py install for matplotlib
    Running command /usr/bin/python -c "import setuptools;__file__='/home/jonathan/build/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-27uup9-record/install-record.txt
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.3.1]
                    python: yes [2.7.3 (default, Sep 26 2013, 20:08:41)  [GCC
                            4.6.3]]
                  platform: yes [linux2]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.6.1]
                  dateutil: yes [using dateutil version 1.5]
                   tornado: yes [tornado was not found. It is required for the
                            WebAgg backend. pip/easy_install may attempt to
                            install it after matplotlib.]
                 pyparsing: yes [pyparsing was not found. It is required for
                            mathtext support. pip/easy_install may attempt to
                            install it after matplotlib.]
                     pycxx: yes [Couldn't import.  Using local copy.]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
                  freetype: yes [version 14.0.8]
                       png: yes [pkg-config information for 'libpng' could not
                            be found. Using unknown version.]

    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]

    OPTIONAL BACKEND EXTENSIONS
                    macosx: no  [Mac OS-X only]
                    qt4agg: no  [PyQt4 not found]
                   gtk3agg: yes [installing, version 3.2.4]
                 gtk3cairo: yes [installing, version 3.2.4]
                    gtkagg: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                            be found.  You may need to install the development
                            package.]
                     tkagg: no  [The C/C++ header for Tk (tk.h) could not be
                            found.  You may need to install the development
                            package.]
                     wxagg: no  [requires wxPython]
                       gtk: no  [The C/C++ header for gtk (gtk/gtk.h) could not
                            be found.  You may need to install the development
                            package.]
                       agg: yes [installing]
                     cairo: yes [installing, version 1.8.8]
                 windowing: no  [Microsoft Windows only]

    OPTIONAL LATEX DEPENDENCIES
                    dvipng: no
               ghostscript: yes [version 9.05]
                     latex: no
                   pdftops: yes [version 0.18.4]

    running install
    running build
    running build_py
    copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-i686-2.7/matplotlib/mpl-data
    running build_ext
    building 'matplotlib._png' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib__png_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/usr/include/python2.7 -c src/_png.cpp -o build/temp.linux-i686-2.7/src/_png.o
    src/_png.cpp:10:20: fatal error: png.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/jonathan/build/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-27uup9-record/install-record.txt:
    ============================================================================

Edit setup.cfg to change the build options



BUILDING MATPLOTLIB

            matplotlib: yes [1.3.1]

                python: yes [2.7.3 (default, Sep 26 2013, 20:08:41)  [GCC

                        4.6.3]]

              platform: yes [linux2]



REQUIRED DEPENDENCIES AND EXTENSIONS

                 numpy: yes [version 1.6.1]

              dateutil: yes [using dateutil version 1.5]

               tornado: yes [tornado was not found. It is required for the

                        WebAgg backend. pip/easy_install may attempt to

                        install it after matplotlib.]

             pyparsing: yes [pyparsing was not found. It is required for

                        mathtext support. pip/easy_install may attempt to

                        install it after matplotlib.]

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

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

                        be found. Using local copy.]

              freetype: yes [version 14.0.8]

                   png: yes [pkg-config information for 'libpng' could not

                        be found. Using unknown version.]



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]



OPTIONAL BACKEND EXTENSIONS

                macosx: no  [Mac OS-X only]

                qt4agg: no  [PyQt4 not found]

               gtk3agg: yes [installing, version 3.2.4]

             gtk3cairo: yes [installing, version 3.2.4]

                gtkagg: no  [The C/C++ header for gtk (gtk/gtk.h) could not

                        be found.  You may need to install the development

                        package.]

                 tkagg: no  [The C/C++ header for Tk (tk.h) could not be

                        found.  You may need to install the development

                        package.]

                 wxagg: no  [requires wxPython]

                   gtk: no  [The C/C++ header for gtk (gtk/gtk.h) could not

                        be found.  You may need to install the development

                        package.]

                   agg: yes [installing]

                 cairo: yes [installing, version 1.8.8]

             windowing: no  [Microsoft Windows only]



OPTIONAL LATEX DEPENDENCIES

                dvipng: no

           ghostscript: yes [version 9.05]

                 latex: no

               pdftops: yes [version 0.18.4]



running install

running build

running build_py

copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-i686-2.7/matplotlib/mpl-data

running build_ext

building 'matplotlib._png' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib__png_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/usr/include/python2.7 -c src/_png.cpp -o build/temp.linux-i686-2.7/src/_png.o

src/_png.cpp:10:20: fatal error: png.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/home/jonathan/build/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-27uup9-record/install-record.txt failed with error code 1
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 126, in main
    self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 228, in run
    requirement_set.install(install_options, global_options)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1093, in install
    requirement.install(install_options, global_options)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 566, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 255, in call_subprocess
    % (command_desc, proc.returncode))
InstallationError: Command /usr/bin/python -c "import setuptools;__file__='/home/jonathan/build/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-27uup9-record/install-record.txt failed with error code 1

What is causing my matplotlib build to fail? 是什么导致我的matplotlib构建失败? What can I do to fix it? 我该如何解决?

You can simply get all of the above with a stack which as you can see includes various packages. 您可以简单地通过堆栈获得以上所有内容,您可以看到该堆栈包括各种软件包。

sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

It comes from here in case you want to dig more. 如果您想进一步挖掘它,它来自这里

It shouldn't be that hard to install packages, especially on Linux, so i recommend trying some alternatives rather than losing time looking for missing dependencies and stuff. 安装软件包并不难,尤其是在Linux上,因此我建议尝试一些替代方法,而不要浪费时间寻找丢失的依赖项和内容。 Any additional packages can be installed manually. 任何其他软件包都可以手动安装。

Although it took some additional fiddling, the answer provided by Paul H in the comments section of the original post was what I was looking for. 尽管还需要一些摆弄,但是Paul H在原始帖子的评论部分中提供的答案正是我想要的。 I have pasted his comment here: 我在这里粘贴了他的评论:

"It looks like you're missing libpng. Try sudo apt-get build-dep python-matplotlib. That should install all the dependancies required to actully install MPL from pip." “看来您缺少libpng。尝试sudo apt-get build-dep python-matplotlib。这应该安装从pip手动安装MPL所需的所有依赖项。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM