前提・実現したいこと
pythonの仮想環境にpsycopg2がインストールしようとすると、エラーメッセージが出力されます。
環境は以下の通りです
■OS
Amazon Linux2
■Pythonバージョン
Python3.7
■PostgreSQLバージョン
PostgreSQL10.4
発生している問題・エラーメッセージ
長いですが、要約するとgccが実行できずにエラーとなっているようです。
ネットで調査したところ、postgresql-develのインストールが必要とありましたが、インストール済みです
(venv) [ec2-user@ip-XXXXX ~]$ python3 -m pip install psycopg2 Collecting psycopg2 Using cached https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz Installing collected packages: psycopg2 Running setup.py install for psycopg2 ... error ERROR: Command errored out with exit status 1: command: /home/ec2-user/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b446bh0y/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b446bh0y/psycopg2/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-9snny2fx/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/venv/include/site/python3.7/psycopg2 cwd: /tmp/pip-install-b446bh0y/psycopg2/ Complete output (40 lines): running install running build running build_py creating build creating build/lib.linux-x86_64-3.7 creating build/lib.linux-x86_64-3.7/psycopg2 copying lib/pool.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/errorcodes.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/sql.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/extras.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/_range.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/__init__.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/extensions.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/tz.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/_json.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/errors.py -> build/lib.linux-x86_64-3.7/psycopg2 copying lib/compat.py -> build/lib.linux-x86_64-3.7/psycopg2 running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-x86_64-3.7 creating build/temp.linux-x86_64-3.7/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.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100004 -DHAVE_LO64=1 -I/home/ec2-user/venv/include -I/usr/include/python3.7m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement In file included from psycopg/psycopgmodule.c:27:0: ./psycopg/psycopg.h:34:10: fatal error: Python.h: No such file or directory #include <Python.h> ^~~~~~~~~~ compilation terminated. 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 <http://initd.org/psycopg/docs/install.html>). error: command 'gcc' failed with exit status 1 ---------------------------------------- ERROR: Command errored out with exit status 1: /home/ec2-user/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b446bh0y/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b446bh0y/psycopg2/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-9snny2fx/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/venv/include/site/python3.7/psycopg2 Check the logs for full command output.
補足情報(FW/ツールのバージョンなど)
インストール済みのpostgreSQLパッケージ一覧です
(venv) [ec2-user@ip-XXXXX ~]$ yum list installed | grep postgres postgresql.x86_64 10.4-5.amzn2.0.2 @amzn2extra-postgresql10 postgresql-contrib.x86_64 10.4-5.amzn2.0.2 @amzn2extra-postgresql10 postgresql-devel.x86_64 10.4-5.amzn2.0.2 @amzn2extra-postgresql10 postgresql-libs.x86_64 10.4-5.amzn2.0.2 @amzn2extra-postgresql10 postgresql-server.x86_64 10.4-5.amzn2.0.2 @amzn2extra-postgresql10
回答1件
あなたの回答
tips
プレビュー