python - Ubuntu 12.04 LTS VirtualBox VM 和 Python 2.7.3 - 'sudo pip install matplotlib' fatal error

标签 python linux python-2.7 ubuntu matplotlib

我正在将各种 Python 库安装到最近从头开始创建的 Ubuntu Linux 12.04 LTS VirtualBox 虚拟机上。这样我就可以在自己的机器上完成一些与 Python 相关的大学工作。我的讲师向我提供的资源建议我运行以下命令来启动和运行我需要的包:

$ 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

我很快发现第二个命令有错误,因此我将其更改为 $ sudo pip install matplotlib ... 然后重新运行它。

但是,在重新运行期间,我遇到了一个错误,因为未安装 Freetype,所以无法构建 matplotlib。因此,我按照 Stackoverflow 帖子“Ubuntu running `pip install` gives error 'The following required packages can not be built: * freetype'”在我的系统上安装了所需的 libfreetype6 软件包。

这导致了我当前的问题。我构建 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

是什么导致我的 matplotlib 构建失败?我可以做什么来修复它?

最佳答案

您可以简单地通过一个堆栈获取上述所有内容,如您所见,其中包含各种包。

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

来自here如果你想挖掘更多。

安装软件包应该不难,尤其是在 Linux 上,所以我建议尝试一些替代方案,而不是浪费时间寻找缺少的依赖项和东西。任何其他软件包都可以手动安装。

关于python - Ubuntu 12.04 LTS VirtualBox VM 和 Python 2.7.3 - 'sudo pip install matplotlib' fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21731221/

相关文章:

python - 修改 matplotlib 中默认 xtick 标签的方向

python - 将其中包含数字的文件分组和划分到单独的文件夹中

使用通过文件的mysql密码特殊字符限制

python - 处理缺失数据,使用数据帧值填充 nan,进行插值

Python2 : Resize image plotted using Matplotlib

python:将字符串的二维列表转换为 float

python - 试图查看列表中的一项是否在另一项中

c++ - X 因应用程序而挂起(使用 C++、Qt、OpenGL)

linux - musl 无法将 libc.a 链接到共享库

python - 在 Mac 上的 Docker 中运行 Keras 时出现内存问题