V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Lucups
V2EX  ›  Python

求助:CentOS 6.3 下安装 matplotlib 失败。。。

  •  
  •   Lucups · 2014-06-11 18:50:24 +08:00 · 5865 次点击
    这是一个创建于 3821 天前的主题,其中的信息可能已经有所发展或是发生改变。
    情况说明:

    centos
    python 2.6.x
    matplotlib 1.3.1

    1. 直接用 yum install python-matplotlib 安装, python代码中引用 matplotlib 提示找不到该模块;

    2. 用 pip install matplotlib 安装提示如下错误:

    ```
    Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/matplotlib/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read() --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/matplotlib
    Traceback (most recent call last):
    File "/usr/bin/pip", line 11, in <module>
    sys.exit(main())
    File "/usr/local/python27/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
    File "/usr/local/python27/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 105: ordinal not in range(128)
    ```

    3. 下载源码解压后用 Python setup.py install 安装报如下错误:

    building 'matplotlib._png' extension
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib__png_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/python27/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/usr/include/libpng12 -I/usr/local/python27/include/python2.7 -c src/_png.cpp -o build/temp.linux-x86_64-2.7/src/_png.o
    In file included from /usr/local/python27/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1804,
    from /usr/local/python27/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
    from /usr/local/python27/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
    from src/_png.cpp:28:
    /usr/local/python27/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
    src/_png.cpp:243:48: error: macro "npy_PyFile_DupClose" requires 3 arguments, but only 2 given
    src/_png.cpp:264:44: error: macro "npy_PyFile_DupClose" requires 3 arguments, but only 2 given
    src/_png.cpp:577:44: error: macro "npy_PyFile_DupClose" requires 3 arguments, but only 2 given
    In file included from src/file_compat.h:4,
    from src/_png.cpp:31:
    /usr/local/python27/lib/python2.7/site-packages/numpy/core/include/numpy/npy_3kcompat.h: In function ?.yObject* npy_PyFile_OpenFile(PyObject*, const char*)?.
    /usr/local/python27/lib/python2.7/site-packages/numpy/core/include/numpy/npy_3kcompat.h:348: warning: deprecated conversion from string constant to ?.har*?
    /usr/local/python27/lib/python2.7/site-packages/numpy/core/include/numpy/npy_3kcompat.h: In function ?.nt npy_PyFile_CloseFile(PyObject*)?.
    /usr/local/python27/lib/python2.7/site-packages/numpy/core/include/numpy/npy_3kcompat.h:356: warning: deprecated conversion from string constant to ?.har*?
    src/_png.cpp: In member function ?.y::Object _png_module::write_png(const Py::Tuple&)?.
    src/_png.cpp:243: error: ?.py_PyFile_DupClose?.was not declared in this scope
    src/_png.cpp:264: error: ?.py_PyFile_DupClose?.was not declared in this scope
    src/_png.cpp: In member function ?.yObject* _png_module::_read_png(const Py::Object&, bool, int)?.
    src/_png.cpp:329: warning: deprecated conversion from string constant to ?.har*?
    src/_png.cpp:577: error: ?.py_PyFile_DupClose?.was not declared in this scope
    error: command 'gcc' failed with exit status 1

    实在是没有力气了。。。
    3 条回复    2014-06-13 13:21:55 +08:00
    heqing
        1
    heqing  
       2014-06-12 14:04:52 +08:00   ❤️ 1
    看起来好象numpy版本不对
    kmcool
        2
    kmcool  
       2014-06-12 14:28:06 +08:00   ❤️ 1
    用anaconda不行么
    Lucups
        3
    Lucups  
    OP
       2014-06-13 13:21:55 +08:00
    @heqing
    @kmcool

    找到原因了。之前因为某个原因需要安装 Python 2.7,由于 yum 不支持 Python 2.7,所以给 yum 保留了 Python 2.6,这直接导致了以上这个问题。

    我换回了 Python 2.6,然后再进行安装,木有问题了~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5885 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 03:28 · PVG 11:28 · LAX 19:28 · JFK 22:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.