티스토리 뷰
개발/python
[PIP] fatal error: Python.h: No such file or director 오류 해결 방법 (centos)
정선생 2023. 6. 5. 00:00반응형
PyHive 모듈을 테스트하려고 sasl 모듈을 설치하는데 아래와 같은 오류가 발생했다.
이런 이유가 나는건 Python 라이브러리중 일부는 직접 빌드를 해야하기 때문에 gcc 같은 컴파일도구가 존재해야 하거나, 의존된 c 라이브러리가 있어야 설치되는 경우가 종종 있다. 하지만 여기서 나온 에러는 python devel 패키지가 없기 때문이고 이를 설치해주면 된다.
fatal error: Python.h: No such file or directory
$ pip install sasl==0.3.1
Collecting sasl==0.3.1
Using cached sasl-0.3.1.tar.gz (44 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: six in ./py-hive/lib/python3.6/site-packages (from sasl==0.3.1) (1.16.0)
Building wheels for collected packages: sasl
Building wheel for sasl (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home1/myUser/py-hive/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0yqvuy_k/sasl_0dee682dd3f84d7298d4ddffd1ca76c5/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0yqvuy_k/sasl_0dee682dd3f84d7298d4ddffd1ca76c5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-rwlfxx4j
cwd: /tmp/pip-install-0yqvuy_k/sasl_0dee682dd3f84d7298d4ddffd1ca76c5/
Complete output (29 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/sasl
...생략....
creating build/temp.linux-x86_64-3.6/sasl
gcc -pthread -Wno-unused-result -Wsign-compare -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 -Isasl -I/home1/myUser/py-hive/include -I/usr/include/python3.6m -c sasl/saslwrapper.cpp -o build/temp.linux-x86_64-3.6/sasl/saslwrapper.o
sasl/saslwrapper.cpp:4:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for sasl
Running setup.py clean for sasl
Failed to build sasl
Installing collected packages: sasl
Running setup.py install for sasl ... error
ERROR: Command errored out with exit status 1:
command: /home1/myUser/py-hive/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0yqvuy_k/sasl_0dee682dd3f84d7298d4ddffd1ca76c5/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0yqvuy_k/sasl_0dee682dd3f84d7298d4ddffd1ca76c5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-9aolrkek/install-record.txt --single-version-externally-managed --compile --install-headers /home1/myUser/py-hive/include/site/python3.6/sasl
cwd: /tmp/pip-install-0yqvuy_k/sasl_0dee682dd3f84d7298d4ddffd1ca76c5/
Complete output (31 lines):
running install
...생략...
gcc -pthread -Wno-unused-result -Wsign-compare -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 -Isasl -I/home1/myHome/py-hive/include -I/usr/include/python3.6m -c sasl/saslwrapper.cpp -o build/temp.linux-x86_64-3.6/sasl/saslwrapper.o
sasl/saslwrapper.cpp:4:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home1/myHome/py-hive/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0yqvuy_k/sasl_0dee682dd3f84d7298d4ddffd1ca76c5/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0yqvuy_k/sasl_0dee682dd3f84d7298d4ddffd1ca76c5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-9aolrkek/install-record.txt --single-version-externally-managed --compile --install-headers /home1/myHome/py-hive/include/site/python3.6/sasl Check the logs for full command output.
해결방법
python의 버전에 따라 아래와 같이 yum 을 통해 설치하면 해결된다.
나는 python3 버전에서 설치중이었기 때문에 python3-devel 을 설치후 빌드가 성공적으로 끝나고 해당 라이브러리 설치가 정상적으로 완료되었다.
# python 2.x 일 경우
sudo yum install python-devel
# python 3.x 일 경우
sudo yum install python3-devel
반응형
'개발 > python' 카테고리의 다른 글
[PIP] gcc: error trying to exec 'cc1plus': execvp: No such file or directory 오류 해결방법 (0) | 2023.06.06 |
---|---|
[오류] pip install --upgrade pip 설치시 오류 해결방법 (0) | 2022.10.03 |
댓글