Dar*_*ech 105 python pip matplotlib virtualenv
我正在尝试在新的virtualenv中安装matplotlib.
当我做:
pip install matplotlib
Run Code Online (Sandbox Code Playgroud)
要么
pip install http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
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
Run Code Online (Sandbox Code Playgroud)
任何人都知道发生了什么事?
任何帮助非常感谢.
Joe*_*ton 176
构建Matplotlib需要libpng(以及freetype同样)不是python库,因此pip不处理安装它(或freetype).
您需要按照libpng-devel和freetype-devel(或者等效于您的操作系统)的方式安装一些东西.
请参阅matplotlib 的建筑要求/说明.
Lav*_*ham 50
要以png格式生成图形,您需要安装以下依赖包
sudo apt-get install libpng-dev
sudo apt-get install libfreetype6-dev
Run Code Online (Sandbox Code Playgroud)
Ubuntu https://apps.ubuntu.com/cat/applications/libpng12-0/ 或使用以下命令
sudo apt-get install libpng12-0
Run Code Online (Sandbox Code Playgroud)
Rob*_*eth 30
由于我已经两次努力解决这个问题(即使在新的kubuntu 15.04安装之后)并且安装freetype并没有解决任何问题,我进一步调查了.
解决方案:
来自github问题:
如果未安装pkg-config,则只会出现此错误;
一个简单的
sudo apt-get install pkg-config
将支持现在的包含路径.
安装完成后顺利进行.
cip*_*hor 26
作为补充,在Amazon EC2上,我需要做的是:
sudo yum install freetype-devel
sudo yum install libpng-devel
sudo pip install matplotlib
Run Code Online (Sandbox Code Playgroud)
在OSX上,我能够通过以下方式安装matplotlib:
pip install matplotlib==1.4.0
Run Code Online (Sandbox Code Playgroud)
只有在我跑完之后:
brew install freetype
Run Code Online (Sandbox Code Playgroud)
在Windows下,这对我有用:
python -m pip install -U pip setuptools
python -m pip install matplotlib
Run Code Online (Sandbox Code Playgroud)
(来自https://matplotlib.org/users/installing.html)