我正在尝试在新的 virtualenv 中安装 matplotlib。
当我这样做时:
pip install matplotlib
或
pip install http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz
我收到此错误:
building 'matplotlib._png' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC - DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/usr/local/include -I/usr/include -I. -I/home/sam/django-projects/datazone/local/lib/python2.7/site-packages/numpy/core/include -I. -I/usr/include/python2.7 -c src/_png.cpp -o build/temp.linux-x86_64-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
有人知道发生了什么吗?
非常感谢任何帮助。
最佳答案
构建 Matplotlib 需要 libpng
(以及 freetype
),它不是 python 库,所以 pip
不处理安装它(或 freetype
)。
您需要按照 libpng-devel
和 freetype-devel
(或适用于您的操作系统的任何等效项)安装一些东西。
见 building requirements/instructions对于 matplotlib。
关于python - 使用 virtualenv 安装 Matplotlib 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9829175/