質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

2回答

7474閲覧

matplotlibインストール時に発生したエラーの対処法がわからない

Tatsuo_Iriyama

総合スコア50

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2018/10/15 04:02

編集2018/10/15 04:27

##現状

現在Pythonを使用して機械学習を勉強しています。

そこでヒストグラムを使用して可視化する為
import matplotlib.pyplot as plt
をしているのですが、Djangoで行なっている為モジュールが存在しないというエラーが発生しました。

なので、matplotlibをインストールしようと思い実行していたのですが、インストール中に

コンパイルを停止しました。 error: command 'gcc' failed with exit status 1

このようなログが表示され、さらに

コンパイルを停止しました。 error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-JxgJ1K/subprocess32/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-dYQhY8/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-JxgJ1K/subprocess32/

このようなエラーが表示されmatplotlibがインストールできずにいます。

##問題点

  1. このエラーではどういったことを言っているのか
  2. このエラーの対策はなのか

この2点になります。
どうぞよろしくお願い致します。

※わからない部分ありましたら、修正依頼等で質問して下さい。

##追記

[vagrant@local sample]$ sudo pip install matplotlib Collecting matplotlib Using cached https://files.pythonhosted.org/packages/59/08/04933377dc4500e3698e93f9113dc3624874e0914f4c85767ecb5b389084/matplotlib-2.2.3-cp27-cp27mu-manylinux1_x86_64.whl Requirement already satisfied: six>=1.10 in /usr/lib/python2.7/site-packages (from matplotlib) (1.11.0) Requirement already satisfied: python-dateutil>=2.1 in /usr/lib/python2.7/site-packages (from matplotlib) (2.7.3) Requirement already satisfied: pytz in /usr/lib/python2.7/site-packages (from matplotlib) (2018.5) Requirement already satisfied: kiwisolver>=1.0.1 in /usr/lib64/python2.7/site-packages (from matplotlib) (1.0.1) Requirement already satisfied: numpy>=1.7.1 in /usr/lib64/python2.7/site-packages (from matplotlib) (1.15.2) Requirement already satisfied: cycler>=0.10 in /usr/lib/python2.7/site-packages (from matplotlib) (0.10.0) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/lib/python2.7/site-packages (from matplotlib) (2.2.2) Requirement already satisfied: backports.functools-lru-cache in /usr/lib/python2.7/site-packages (from matplotlib) (1.5) Collecting subprocess32 (from matplotlib) Using cached https://files.pythonhosted.org/packages/be/2b/beeba583e9877e64db10b52a96915afc0feabf7144dcbf2a0d0ea68bf73d/subprocess32-3.5.3.tar.gz Requirement already satisfied: setuptools in /usr/lib/python2.7/site-packages (from kiwisolver>=1.0.1->matplotlib) (40.4.3) Building wheels for collected packages: subprocess32 Running setup.py bdist_wheel for subprocess32 ... error Complete output from command /bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-JxgJ1K/subprocess32/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-_6DKQR --python-tag cp27: running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-2.7 copying subprocess32.py -> build/lib.linux-x86_64-2.7 running build_ext running build_configure checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for unistd.h... (cached) yes checking fcntl.h usability... yes checking fcntl.h presence... yes checking for fcntl.h... yes checking signal.h usability... yes checking signal.h presence... yes checking for signal.h... yes checking sys/cdefs.h usability... yes checking sys/cdefs.h presence... yes checking for sys/cdefs.h... yes checking for sys/types.h... (cached) yes checking for sys/stat.h... (cached) yes checking sys/syscall.h usability... yes checking sys/syscall.h presence... yes checking for sys/syscall.h... yes checking for dirent.h that defines DIR... yes checking for library containing opendir... none required checking for pipe2... yes checking for setsid... yes checking whether dirfd is declared... yes configure: creating ./config.status config.status: creating _posixsubprocess_config.h building '_posixsubprocess32' extension creating build/temp.linux-x86_64-2.7 gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c _posixsubprocess.c -o build/temp.linux-x86_64-2.7/_posixsubprocess.o _posixsubprocess.c:16:20: 致命的エラー: Python.h: そのようなファイルやディレクトリはありません #include "Python.h" ^ コンパイルを停止しました。 error: command 'gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for subprocess32 Running setup.py clean for subprocess32 Failed to build subprocess32 Installing collected packages: subprocess32, matplotlib Running setup.py install for subprocess32 ... error Complete output from command /bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-JxgJ1K/subprocess32/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-dYQhY8/install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build/lib.linux-x86_64-2.7 copying subprocess32.py -> build/lib.linux-x86_64-2.7 running build_ext running build_configure _posixsubprocess_config.h is already up to date. building '_posixsubprocess32' extension creating build/temp.linux-x86_64-2.7 gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c _posixsubprocess.c -o build/temp.linux-x86_64-2.7/_posixsubprocess.o _posixsubprocess.c:16:20: 致命的エラー: Python.h: そのようなファイルやディレクトリはありません #include "Python.h" ^ コンパイルを停止しました。 error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-JxgJ1K/subprocess32/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-dYQhY8/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-JxgJ1K/subprocess32/

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hayataka2049

2018/10/15 04:26 編集

そのメッセージの上に大量に何かが出ていると思うので、それをぜんぶコピペして掲載してください
hayataka2049

2018/10/15 04:33 編集

一応確認したいのですが、使いたいpythonはシステムにプリインストールされているpython2.7で間違いありませんか?
guest

回答2

0

ベストアンサー

build-essential的なものを入れてないなら、まずはこれを。

$ sudo yum groupinstall "Development Tools"

参考:CentOSのDevelopment Tools

あと、python用の開発ツールも入れてください。

$ sudo yum install python-devel

投稿2018/10/15 04:44

編集2018/10/15 04:45
hayataka2049

総合スコア30933

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Tatsuo_Iriyama

2018/10/15 04:50

回答ありがとうございます。 問題解決しました! 確認なのですが、今回の問題点はどう言った事だったのでしょうか?
hayataka2049

2018/10/15 04:59

matplotlibが依存するsubprocess32のビルドでコケた subprocess32はpythonだけでなくC言語も使って書かれていて、コンパイルにはpythonのC拡張などに関連するライブラリやヘッダファイルが必要だった $ sudo yum install python-devel でそれを入れた という感じですね
Tatsuo_Iriyama

2018/10/15 05:12

なるほど、理解しました! ありがとうございました
guest

0

C++ をコンパイルするコマンド gcc がないと言っています。
pip でモジュールをインストールする際、gcc でコンパイルをしようとしたが、アプリケーションが存在しないのでエラーになっています。

以下で gcc をインストールしてから、再度試してはどうでしょうか。

sudo apt-get install build-essential

投稿2018/10/15 04:11

tiitoi

総合スコア21956

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

Tatsuo_Iriyama

2018/10/15 04:17

ご回答ありがとうございます。 コマンド実行しましたら、 sudo: apt-get: コマンドが見つかりません となりました。 CentOSで開発していますので、コマンドが異なると思われます。
tiitoi

2018/10/15 04:33

環境構築の質問の際は OS や Python のバージョンなどを質問欄に記載するようにしてください。 CentOS なら yum install gcc でインストールできないでしょうか?
hayataka2049

2018/10/15 04:37 編集

@tiitoiさん gccがないということはないかと 今回は「Python.h: そのようなファイルやディレクトリはありません」が直接の原因で、python-devの類を入れていないか、入れててもインクルードパスが通ってない等の可能性が考えられます
tiitoi

2018/10/15 04:45

質問をぱっと見で回答を書いてしまったので、`command not found` だと思い込んでいました。ご指摘ありがとうございます。 たしかに `command 'gcc' failed with exit status 1`なので、コンパイルのエラーですね。 ubuntu なら apt-get install -y python-dev (Python3 なら python3-dev) でヘッダー等含めて入りますが、CentOS ではどうでしょうか。
Tatsuo_Iriyama

2018/10/15 05:13

回答ありがとうございます。 >環境構築の質問の際は OS や Python のバージョンなどを質問欄に記載するようにしてください。 次回以降記載しようと思います。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問