web-dev-qa-db-ja.com

仮想環境でのPipインストールMatplotlibエラー

Matplotlibを新しいvirtualenvにインストールしようとしています。

私がする時:

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

誰が何が起こっているのか知っていますか?

助けていただければ幸いです。

104
Darwin Tech

Matplotlibのビルドにはpythonライブラリではないlibpng(およびfreetypeも)が必要であるため、pipはインストールを処理しません(またはfreetype)。

libpng-develfreetype-devel(またはOSに相当するもの)の行に沿って何かをインストールする必要があります。

Matplotlibの 構築要件/手順 を参照してください。

176
Joe Kington

Png形式でグラフを生成するには、次の依存パッケージをインストールする必要があります

Sudo apt-get install libpng-dev
Sudo apt-get install libfreetype6-dev

Ubuntu https://apps.ubuntu.com/cat/applications/libpng12-0/ または次のコマンドを使用

Sudo apt-get install libpng12-0
50
Lava Sangeetham

私はこの問題に2度苦労しており(kubuntu 15.04を新しくインストールした後でも)、freetypeをインストールしても何も解決しないので、さらに調査しました。

解決策:
github issueから:

このバグは、pkg-configがインストールされていない場合にのみ発生します。
シンプルな
Sudo apt-get install pkg-config
今のところインクルードパスを強化します。

このインストールがスムーズに進行した後。

30
Robin Nemeth

補足として、Amazon EC2で必要なことは次のとおりです。

Sudo yum install freetype-devel
Sudo yum install libpng-devel
Sudo pip install matplotlib
26
ciphor

OSXでは、matplotlibを次の方法でインストールできました。

pip install matplotlib==1.4.0

私が走った後にのみ:

brew install freetype
8
gh4x

Windowsではこれは私のために働いた:

python -m pip install -U pip setuptools
python -m pip install matplotlib

https://matplotlib.org/users/installing.html から)

5
ralfiii
Sudo apt-get install libpng-dev libjpeg8-dev libfreetype6-dev

ubuntu 14.04で私のために働いた

2
user2436428

もう1つのオプションはanacondaをインストールすることです。これには、Matplotlib、numpy、pandasなどのパッケージが付属しています。

https://anaconda.org

0

上記の回答はどれもMintではうまくいきませんでした。

Sudo apt-get install build-essential g++
0
AndreL

インストールするのに必要なパッケージを減らすには、必要なだけです

apt-get install -y \
    libfreetype6-dev \
    libxft-dev && \
    pip install matplotlib

次のパッケージがローカルにインストールされます

Collecting matplotlib
  Downloading matplotlib-2.2.0-cp35-cp35m-manylinux1_x86_64.whl (12.5MB)
Collecting pytz (from matplotlib)
  Downloading pytz-2018.3-py2.py3-none-any.whl (509kB)
Collecting python-dateutil>=2.1 (from matplotlib)
  Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
  Downloading pyparsing-2.2.0-py2.py3-none-any.whl (56kB)
Requirement already satisfied: six>=1.10 in /opt/conda/envs/pytorch-py35/lib/python3.5/site-packages (from matplotlib)
Collecting cycler>=0.10 (from matplotlib)
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Collecting kiwisolver>=1.0.1 (from matplotlib)
  Downloading kiwisolver-1.0.1-cp35-cp35m-manylinux1_x86_64.whl (949kB)
Requirement already satisfied: numpy>=1.7.1 in /opt/conda/envs/pytorch-py35/lib/python3.5/site-packages (from matplotlib)
Requirement already satisfied: setuptools in /opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.Egg (from kiwisolver>=1.0.1->matplotlib)
Installing collected packages: pytz, python-dateutil, pyparsing, cycler, kiwisolver, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.0.1 matplotlib-2.2.0 pyparsing-2.2.0 python-dateutil-2.6.1 pytz-2018.3
0
loretoparisi

MacOSxの場合

xcode-select --install

これは、失敗の理由であるsubprocess 32に準拠しています。

0
Coderaemon