简体   繁体   English

用python3安装matplotlib时gcc错误

[英]error with gcc when install matplotlib with python3

I'm trying to install matplotlib with python3 as mentionned in How to install matplotlib with Python3.2 . 我正在尝试使用python3安装matplotlib ,如如何使用Python3.2安装matplotlib所述 An error occurs: command 'gcc' failed with exit status 1 when i do 发生错误:我执行命令“ gcc”失败,退出状态为1

python3 setup.py build

 basedirlist is: ['/usr/local', '/usr']
 ============================================================================
 BUILDING MATPLOTLIB
        matplotlib: 1.3.x
            python: 3.2.3 (default, Sep 10 2012, 18:14:40)  [GCC 4.6.3]
          platform: linux2

 REQUIRED DEPENDENCIES
             numpy: 1.6.1
         freetype2: found, but unknown version (no pkg-config)
                    * WARNING: Could not find 'freetype2' headers in any
                    * of '/usr/local/include', '/usr/include',
                    * '/usr/local/include', '/usr/include', '.',
                    * '/usr/local/include/freetype2',
                    * '/usr/include/freetype2',
                    * '/usr/local/include/freetype2',
                    * '/usr/include/freetype2', './freetype2'.

OPTIONAL BACKEND DEPENDENCIES
            libpng: found, but unknown version (no pkg-config)
                    * Could not find 'libpng' headers in any of
                    * '/usr/local/include', '/usr/include',
                    * '/usr/local/include', '/usr/include', '.'
           Tkinter: no
                    * Using default library and include directories for
                    * Tcl and Tk because a Tk window failed to open.
                    * You may need to define DISPLAY for Tk to work so
                    * that setup can determine where your libraries are
                    * located. Tkinter present, but header files are not
                    * found. You may need to install development
                    * packages.
              Gtk+: no
                    * Building for Gtk+ requires pygtk; you must be able
                     * to "import gtk" in your build/install environment
    Mac OS X native: no
                Qt: no
               Qt4: no
            PySide: no
             Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
          dateutil: matplotlib will provide
              pytz: matplotlib will provide
               six: matplotlib will provide
adding pytz

OPTIONAL USETEX DEPENDENCIES
            dvipng: 1.14
       ghostscript: 9.05
             latex: 3.1415926
           pdftops: 0.18.4

[Edit setup.cfg to suppress the above messages]
============================================================================
pymods ['pylab', 'six']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor',   'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil.zoneinfo']
running install
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-x86_64- 3.2/matplotlib/mpl-data

running build_ext
building 'matplotlib.ft2font' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector --param=ssp-buffer- size=4 -Wformat -Wformat-security -Werror=format-security -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -DPYCXX_PYTHON_2TO3=1 -I/usr/local/include -I/usr/include -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/lib/python3/dist-packages/numpy/core/include/freetype2 -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I./freetype2 - I/usr/include/python3.2mu -c src/ft2font.cpp -o build/temp.linux-x86_64-3.2/src/ft2font.o
In file included from ./CXX/Extensions.hxx:37:0,
             from src/ft2font.h:6,
             from src/ft2font.cpp:3:
./CXX/WrapPython.h:58:20: erreur fatale: Python.h : Aucun fichier ou dossier de ce type
compilation terminée.
error: command 'gcc' failed with exit status 1

I tried the answer in the post error: command 'gcc' failed with exit status 1 while installing eventlet but obtained the same error. 我在发布错误中尝试了答案:安装eventlet时,命令'gcc'失败,退出状态为1,但获得了相同的错误。 How can i do? 我能怎么做?

You are missing the Python 3 development files (headers and static libraries). 您缺少Python 3开发文件(标头和静态库)。 For example in Ubuntu, you can install the relevant package with: 例如,在Ubuntu中,可以使用以下命令安装相关的软件包:

$ sudo apt-get install python3-dev

You'll also need the freetype2 development package: 您还需要freetype2开发包:

$ sudo apt-get install libfreetype6-dev

I found the solution after installing many libraries... I finally build all the dependancies with: 在安装了许多库之后,我找到了解决方案...我最终通过以下方式建立了所有依赖关系:

 sudo apt-get build-dep python-matplotlib

and after: 之后:

sudo python3 setup.py install

Thanks for your help Pedro 感谢您的帮助Pedro

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

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