본문 바로가기
IT 일반 정보

Building wheel for psycopg2 setup.py python3.6 에러

by 떠도리c 2024. 8. 26.
반응형

레드햇 7, CentOS 7에서 postgresql 연동 시 발생하는 psycopg2 설치 에러

에러

===

Defaulting to user installation because normal site-packages is not writeable Collecting psycopg2-binary Using cached psycopg2-binary-2.9.6.tar.gz (384 kB) Preparing metadata (setup.py) ... done Using legacy 'setup.py install' for psycopg2-binary, since package 'wheel' is not installed. Installing collected packages: psycopg2-binary Running setup.py install for psycopg2-binary ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cxv4gpxo/psycopg2-binary_2d0c7d7ac2394907b5b6daca80cd9b55/setup.py'"'"'; file='"'"'/tmp/pip-install-cxv4gpxo/psycopg2-binary_2d0c7d7ac2394907b5b6daca80cd9b55/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-dq5c9_wz/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ellie/.local/include/python3.6m/psycopg2-binary cwd: /tmp/pip-install-cxv4gpxo/psycopg2-binary_2d0c7d7ac2394907b5b6daca80cd9b55/ Complete output (34 lines): running install running build running build_py creating build creating build/lib.linux-x86_64-3.6 creating build/lib.linux-x86_64-3.6/psycopg2 copying lib/init.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/_json.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/_range.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/extras.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2 running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/psycopg 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 -DPSYCOPG_VERSION=2.9.6 (dt dec pq3 ext) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=90224 -DPSYCOPG_DEBUG=1 -I/usr/include/python3.6m -I. -I/usr/include -I/usr/include/pgsql/server -I/usr/include/libxml2 -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o -Wdeclaration-after-statement unable to execute 'gcc': No such file or directory

It appears you are missing some prerequisite to build the package from source.

You may install a binary package by installing 'psycopg2-binary' from PyPI. If you want to install psycopg2 from source, please install the packages required for the build and try again.

For further information please check the 'doc/src/install.rst' file (also at https://www.psycopg.org/docs/install.html).

error: command 'gcc' failed with exit status 1

ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cxv4gpxo/psycopg2-binary_2d0c7d7ac2394907b5b6daca80cd9b55/setup.py'"'"'; file='"'"'/tmp/pip-install-cxv4gpxo/psycopg2-binary_2d0c7d7ac2394907b5b6daca80cd9b55/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-dq5c9_wz/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ellie/.local/include/python3.6m/psycopg2-binary Check the logs for full command output.

===

 

 

psycopg2 설치 해결방법

sudo yum groupinstall "Development Tools"
sudo yum install python3-devel
sudo yum install postgresql-libs
sudo yum install postgresql-devel
pip3 install psycopg2

psycopg2는 특정 버전을 명시하여 상황에 맞게 설치해야하는 경우도 있다.
예) pip3 install psycopg2==2.8

 

반응형