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

2014-06-11 18:50:24 +08:00
 Lucups
情况说明:

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

实在是没有力气了。。。
5855 次点击
所在节点    Python
3 条回复
heqing
2014-06-12 14:04:52 +08:00
看起来好象numpy版本不对
kmcool
2014-06-12 14:28:06 +08:00
用anaconda不行么
Lucups
2014-06-13 13:21:55 +08:00
@heqing
@kmcool

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

我换回了 Python 2.6,然后再进行安装,木有问题了~

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/116956

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX