2014-02-12 64 views
0

我正在將各種Python庫安裝到最近從頭創建的Ubuntu Linux 12.04 LTS VirtualBox VM上。這樣我就可以在自己的機器上完成一些Python相關的大學工作。我被我的講師來運行下面的命令來獲得我需要了包,正在運行的給我資源的建議:Ubuntu 12.04 LTS VirtualBox VM&Python 2.7.3 - 'sudo pip install matplotlib'致命錯誤

$ 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 ...重新運行之前。

但是,在重新運行期間,我遇到了matplotlib無法構建的錯誤,因爲未安裝Freetype。所以我遵循這個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構建失敗?我能做些什麼來解決它?

+2

看起來你缺少'libpng'。試試'sudo apt-get build-dep python-matplotlib'。 *應該*安裝從'pip'實施安裝MPL所需的所有依賴關係。 –

+0

我目前正在嘗試KapelNick的回答,並等待安裝軟件包。之後我會嘗試你的解決方案,Paul H,看看我是否已經獲得了你提到的依賴。不久之後我會接受一個合適的答案。 – jbduncan

+0

所以你的問題發生了什麼?你解決了嗎? – 2014-02-12 18:25:16

回答

0

雖然它花了一些額外的手腳,但Paul H在原帖的評論部分提供的答案正是我一直在尋找的。我在這裏貼上了他的評論:

「看起來你缺少libpng,試試sudo apt-get build-dep python-matplotlib。應該安裝從pip安裝MPL所需的所有依賴項。

0

你可以簡單地得到所有上面的堆棧,你可以看到包括各種軟件包。

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

它在你想挖掘更多的情況下,來自here

安裝軟件包不應該很難,特別是在Linux上,所以我建議嘗試一些替代方案,而不是失去時間尋找缺失的依賴關係和東西。任何額外的軟件包都可以手動安裝。

+0

你的回答看起來有些敵意。 – tacaswell

+0

我會編輯我認爲你是對的,我可能在那裏過度擴張。謝謝 – 2014-02-12 16:16:42

相關問題