pip利用時に「致命的エラー: Python.h: そのようなファイルやディレクトリはありません」が発生した場合の対処法
- 作成日 2020.07.16
- 更新日 2020.07.17
- python

pip install実行時に「致命的エラー: Python.h: そのようなファイルやディレクトリはありません」が発生した場合の対処法を記述してます。
環境
- OS CentOS Linux release 8.2.2004 (Core)
- Python 3.6.8
- pip 20.1.1
エラー全文
pipインストール実行時に発生。
pip install locust
エラー全文
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=572 -DPSUTIL_LINUX=1 -I/usr/include/python3.6m -c psutil/_psutil_common.c -o build/temp.linux-x86_64-3.6/psutil/_psutil_common.o
psutil/_psutil_common.c:9:10: 致命的エラー: Python.h: そのようなファイルやディレクトリはありません
#include <Python.h>
^~~~~~~~~~
コンパイルを停止しました。
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.6 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1r1memr0/psutil/setup.py'"'"'; __file__='"'"'/tmp/pip-install-1r1memr0/psutil/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-yakw0w5y/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/testuser/.local/include/python3.6m/psutil Check the logs for full command output.
対処法
gccが入ってないだけと思い、インストールしましたがインストール済みだったので、
sudo yum -y install gcc
python3-develパッケージをインストールすることにより改善されました。
sudo yum install python3-devel
-
前の記事
Mac dockerをインストールする手順 2020.07.16
-
次の記事
dovecot(ダブコット)のバージョン確認方法 2020.07.16
コメントを書く