こんにちは。プログラミング初心者です。
https://qiita.com/mahiroaug/items/b0e23e6ca19c33add1a9
↑のページを参考にvirtualenvを使うところまで進んでいます。
環境
Mac OS Catalina
さくらvps(centos7)
質問内容
pipを使い仮想環境内で、django と gunicorn と postgresql に接続するためのモジュールをインポートしようとした際、ターミナル全面が真っ赤になるくらいのエラーが出ました。
(botenv) []$ pip install django gunicorn psycopg2=3.2 in ./botenv/lib/python3.6/site-packages (from django) (3.2.3)
Requirement already satisfied: django in ./botenv/lib/python3.6/site-packages (3.0.4)
Requirement already satisfied: gunicorn in ./botenv/lib/python3.6/site-packages (20.0.4)
Collecting psycopg2
Using cached psycopg2-2.8.4.tar.gz (377 kB)
Requirement already satisfied: asgiref
Requirement already satisfied: sqlparse>=0.2.2 in ./botenv/lib/python3.6/site-packages (from django) (0.3.1)
Requirement already satisfied: pytz in ./botenv/lib/python3.6/site-packages (from django) (2019.3)
Requirement already satisfied: setuptools>=3.0 in ./botenv/lib/python3.6/site-packages (from gunicorn) (28.8.0)
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/taisei/botenv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-e8mwazxb/psycopg2/setup.py'"'"'; file='"'"'/tmp/pip-install-e8mwazxb/psycopg2/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-k3enm5nl
cwd: /tmp/pip-install-e8mwazxb/psycopg2/
Complete output (42 lines):
/usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)
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/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/compat.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2
copying lib/init.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
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.8.4 (dt dec pq3 ext) -DPG_VERSION_NUM=90224 -I/usr/include/python3.6m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:27:0:
./psycopg/psycopg.h:35:22: 致命的エラー: libpq-fe.h: そのようなファイルやディレクトリはありません
#include <libpq-fe.h>
^
コンパイルを停止しました。
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: Failed building wheel for psycopg2 |
Running setup.py clean for psycopg2 |
Failed to build psycopg2 |
Installing collected packages: psycopg2 |
Running setup.py install for psycopg2 ... error ERROR: Command errored out with exit status 1: command: /home/taisei/botenv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-e8mwazxb/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-e8mwazxb/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-f49la1qu/install-record.txt --single-version-externally-managed --compile --install-headers /home/taisei/botenv/include/site/python3.6/psycopg2 cwd: /tmp/pip-install-e8mwazxb/psycopg2/ Complete output (42 lines): /usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'project_urls' warnings.warn(msg) 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/extras.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/extensions.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/tz.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/compat.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/sql.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/errors.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/errorcodes.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/pool.py -> build/lib.linux-x86_64-3.6/psycopg2 copying lib/__init__.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 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.8.4 (dt dec pq3 ext) -DPG_VERSION_NUM=90224 -I/usr/include/python3.6m -I. -I/usr/include -I/usr/include/pgsql/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.6/psycopg/psycopgmodule.o -Wdeclaration-after-statement In file included from psycopg/psycopgmodule.c:27:0: ./psycopg/psycopg.h:35:22: 致命的エラー: libpq-fe.h: そのようなファイルやディレクトリはありません #include <libpq-fe.h> ^ コンパイルを停止しました。 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/taisei/botenv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-e8mwazxb/psycopg2/setup.py'"'"'; file='"'"'/tmp/pip-install-e8mwazxb/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-f49la1qu/install-record.txt --single-version-externally-managed --compile --install-headers /home/taisei/botenv/include/site/python3.6/psycopg2 Check the logs for full command output.
かなり調べましたが原因がわかりませんので質問させていただきました。原因のわかる方、ご教授願います。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。