I’m having issues building wheel for psycopg2 thru pip install -r requirements.txt
. I’m on ubuntu 20.04 + python 3.8.5 + venv.
This is my requirements.txt:
amqp==2.6.1
anyjson==0.3.3
asgiref==3.2.10
billiard==3.6.3.0
brotlipy==0.7.0
celery==4.4.7
celery-progress==0.0.12
certifi==2020.6.20
cffi==1.14.2
chardet==3.0.4
cryptography==3.1
Django==3.0.3
dj-database-url==0.5.0
django-celery-results==1.2.1
django-cors-headers==3.5.0
django-crispy-forms==1.9.2
django-heroku==0.3.1
django-rest-framework==0.1.0
django-templated-mail==1.1.1
djangorestframework==3.11.1
djoser==2.0.5
fake-useragent==0.1.11
future==0.18.2
gunicorn==20.0.4
httpie==2.2.0
idna==2.10
kombu==4.6.11
lxml==4.5.2
pika==1.1.0
psycopg2==2.8.5
pycparser==2.20
Pygments==2.7.0
pyOpenSSL==19.1.0
PySocks==1.7.1
python-dateutil==2.8.1
python-decouple==3.3
pytz==2020.1
requests==2.24.0
six==1.15.0
SQLAlchemy==1.3.19
sqlparse==0.3.1
urllib3==1.25.10
vine==1.3.0
whitenoise==5.2.0
This is the output when I pip install -r requirements.txt
:
[...]
Collecting urllib3==1.25.10
Using cached urllib3-1.25.10-py2.py3-none-any.whl (127 kB)
Collecting vine==1.3.0
Using cached vine-1.3.0-py2.py3-none-any.whl (14 kB)
Collecting whitenoise==5.2.0
Using cached whitenoise-5.2.0-py2.py3-none-any.whl (19 kB)
Requirement already satisfied: setuptools>=3.0 in ./venv/lib/python3.8/site-packages (from gunicorn==20.0.4->-r requirements.txt (line 24)) (44.0.0)
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/pierre/Workspace/campground_scavanger/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1xr9yjk0/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-1xr9yjk0/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-b8g9assp
cwd: /tmp/pip-install-1xr9yjk0/psycopg2/
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
ERROR: Failed building wheel for psycopg2
Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: vine, amqp, anyjson, asgiref, billiard, pycparser, cffi, brotlipy, kombu, pytz, celery, celery-progress, certifi, chardet, six, cryptography, sqlparse, Django, dj-database-url, django-celery-results, django-cors-headers, django-crispy-forms, whitenoise, psycopg2, django-heroku, djangorestframework, django-rest-framework, django-templated-mail, djoser, fake-useragent, future, gunicorn, idna, urllib3, requests, Pygments, httpie, lxml, pika, pyOpenSSL, PySocks, python-dateutil, python-decouple, SQLAlchemy
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
command: /home/pierre/Workspace/campground_scavanger/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1xr9yjk0/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-1xr9yjk0/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-8dtfz_uf/install-record.txt --single-version-externally-managed --compile --install-headers /home/pierre/Workspace/campground_scavanger/venv/include/site/python3.8/psycopg2
cwd: /tmp/pip-install-1xr9yjk0/psycopg2/
Complete output (40 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120005 -DHAVE_LO64=1 -I/home/pierre/Workspace/campground_scavanger/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
36 | #include <libpq-fe.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
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/pierre/Workspace/campground_scavanger/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1xr9yjk0/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-1xr9yjk0/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-8dtfz_uf/install-record.txt --single-version-externally-managed --compile --install-headers /home/pierre/Workspace/campground_scavanger/venv/include/site/python3.8/psycopg2 Check the logs for full command output.
Googling the first error error: invalid command 'bdist_wheel'
led me to run pip install wheel
in my venv. Successfully installed wheel-0.36.2. Not sure if this is related whatsoever with my psycopg2 issue hereafter but I’m showing all the steps I’m doing.
I then reran pip install -r requirements.txt
and now only the psycopg2 issue shows up:
[...]
Requirement already satisfied: vine==1.3.0 in ./venv/lib/python3.8/site-packages (from -r requirements.txt (line 43)) (1.3.0)
Requirement already satisfied: whitenoise==5.2.0 in ./venv/lib/python3.8/site-packages (from -r requirements.txt (line 44)) (5.2.0)
Requirement already satisfied: setuptools>=3.0 in ./venv/lib/python3.8/site-packages (from gunicorn==20.0.4->-r requirements.txt (line 24)) (44.0.0)
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/pierre/Workspace/campground_scavanger/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zxwqo979/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zxwqo979/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-fknnvsn3
cwd: /tmp/pip-install-zxwqo979/psycopg2/
Complete output (40 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120005 -DHAVE_LO64=1 -I/home/pierre/Workspace/campground_scavanger/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
36 | #include <libpq-fe.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
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-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, django-heroku, djangorestframework, django-rest-framework, django-templated-mail, djoser, fake-useragent, future, gunicorn, urllib3, idna, requests, Pygments, httpie, lxml, pika, pyOpenSSL, PySocks, python-dateutil, python-decouple, SQLAlchemy
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
command: /home/pierre/Workspace/campground_scavanger/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zxwqo979/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zxwqo979/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-r4aij71q/install-record.txt --single-version-externally-managed --compile --install-headers /home/pierre/Workspace/campground_scavanger/venv/include/site/python3.8/psycopg2
cwd: /tmp/pip-install-zxwqo979/psycopg2/
Complete output (40 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120005 -DHAVE_LO64=1 -I/home/pierre/Workspace/campground_scavanger/venv/include -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
36 | #include <libpq-fe.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
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/pierre/Workspace/campground_scavanger/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zxwqo979/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zxwqo979/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-r4aij71q/install-record.txt --single-version-externally-managed --compile --install-headers /home/pierre/Workspace/campground_scavanger/venv/include/site/python3.8/psycopg2 Check the logs for full command output.
I replaced psycopg2==2.8.5
by psycopg2-binary==2.8.5
as per some other stackoverflow threads but the same issue remains during the pip install -r requirements.txt
.
If I install manually psycopg2-binary in my venv it works fine:
(venv) pierre@thinkpad:~/Workspace/campground_scavanger$ pip install psycopg2-binary
Collecting psycopg2-binary
Using cached psycopg2_binary-2.8.6-cp38-cp38-manylinux1_x86_64.whl (3.0 MB)
Installing collected packages: psycopg2-binary
Successfully installed psycopg2-binary-2.8.6
But then again if I comment out psycopg2==2.8.5
(or psycopg2-binary==2.8.5
and rerun pip install -r requirements.txt
, I keep getting the same error message.
I’m not quite sure why there is a Building wheels for collected packages: psycopg2
even if psycopg2 is commented out in my requirements.txt. Dependency with another package?
I’m trying to install the latest version of psycopg2 (2.8.x) with pipenv install psycopg2
, and following what to do suggested by the errors doesn’t change anything. What am I missing here?
The errors I’m seeing are…
./psycopg/psycopg.h:34:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
AND
[pipenv.exceptions.InstallError]: ['Failed building wheel for psycopg2',
- I am developing on Ubuntu 18.04.2 LTS with a fresh install with an up to date system.
- I have python3-dev, python3-testresources, build-essentials, libpq-dev, postgresql-server-dev-all
- I have python 3.7.1 installed and am using pipenv
- pip is 19.0.3
- wheel is 0.33.1
- setuptools is 41.0.0
Tried http://initd.org/psycopg/articles/2018/02/08/psycopg-274-released/
Tried http://initd.org/psycopg/articles/2019/04/04/psycopg-28-released/
Tried https://www.postgresql.org/message-id/CA%2Bmi_8bd6kJHLTGkuyHSnqcgDrJ1uHgQWvXCKQFD3tPQBUa2Bw%40mail.gmail.com
Tried github.com//issues/674
Here is the error:
(fwdev) wazd@burger:~/Projects/fwdev$ pipenv install psycopg2-binary
Installing psycopg2-binary…
Adding psycopg2-binary to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock (26a31f) out of date, updating to (12885b)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (26a31f)!
Installing dependencies from Pipfile.lock (26a31f)…
An error occurred while installing psycopg2==2.8.2 --hash=sha256:00cfecb3f3db6eb76dcc763e71777da56d12b6d61db6a2c6ccbbb0bff5421f8f --hash=sha256:076501fc24ae13b2609ba2303d88d4db79072562f0b8cc87ec1667dedff99dc1 --hash=sha256:4e2b34e4c0ddfeddf770d7df93e269700b080a4d2ec514fec668d71895f56782 --hash=sha256:5cacf21b6f813c239f100ef78a4132056f93a5940219ec25d2ef833cbeb05588 --hash=sha256:61f58e9ecb9e4dc7e30be56b562f8fc10ae3addcfcef51b588eed10a5a66100d --hash=sha256:8954ff6e47247bdd134db602fcadfc21662835bd92ce0760f3842eacfeb6e0f3 --hash=sha256:b6e8c854cdc623028e558a409b06ea2f16d13438335941c7765d0a42b5bedd33 --hash=sha256:baca21c0f7344576346e260454d0007313ccca8c170684707a63946b27a56c8f --hash=sha256:bb1735378770fb95dbe392d29e71405d45c8bdcfa064f916504833a92ab03c55 --hash=sha256:de3d3c46c1ee18f996db42d1eb44cf1565cc9e38fb1dbd9b773ff6b3fa8035d7 --hash=sha256:dee885602bb200bdcb1d30f6da6c7bb207360bc786d0a364fe1540dd14af0bab! Will try again.
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 11/11 — 00:00:09
Installing initially failed dependencies…
pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.7/dist-packages/pipenv/core.py", line 1992, in do_install
[pipenv.exceptions.InstallError]: skip_lock=skip_lock,
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.7/dist-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]: pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.7/dist-packages/pipenv/core.py", line 859, in do_install_dependencies
[pipenv.exceptions.InstallError]: retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.7/dist-packages/pipenv/core.py", line 763, in batch_install
[pipenv.exceptions.InstallError]: _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)
[pipenv.exceptions.InstallError]: File "/usr/local/lib/python3.7/dist-packages/pipenv/core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]: raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Collecting psycopg2==2.8.2 ( ... error: command 'x86_64-linux-gnu-gcc' failed with exit status 1", ' ', ' ----------------------------------------']
[pipenv.exceptions.InstallError]: ['Failed building wheel for psycopg2', 'Command "/home/wazd/.local/share/virtualenvs/fwdev-TAVasR-s/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-utxwtgbp/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-e87i6en_/install-record.txt --single-version-externally-managed --compile --install-headers /home/wazd/.local/share/virtualenvs/fwdev-TAVasR-s/include/site/python3.7/psycopg2" failed with error code 1 in /tmp/pip-install-utxwtgbp/psycopg2/']
AND from pip3 install psycopg2:
(fwdev) wazd@burger:~/Projects/fwdev$ pip3 install psycopg2
Collecting psycopg2
Using cached https://files.pythonhosted.org/packages/23/7e/93c325482c328619870b6cd09370f6dbe1148283daca65115cd63642e60f/psycopg2-2.8.2.tar.gz
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
Complete output from command /home/wazd/.local/share/virtualenvs/fwdev-TAVasR-s/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-zw76s0g_/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-s_gi9bl6 --python-tag cp37:
running bdist_wheel
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/__init__.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/compat.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/_ipaddress.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/_range.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/pool.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.7/psycopg2
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/psycopg
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.2 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100007 -DHAVE_LO64=1 -I/usr/include/python3.7m -I/home/wazd/.local/share/virtualenvs/fwdev-TAVasR-s/include/python3.7m -I. -I/usr/include/postgresql -I/usr/include/postgresql/10/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 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
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
Complete output from command /home/wazd/.local/share/virtualenvs/fwdev-TAVasR-s/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-zw76s0g_/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-he_4xq7_/install-record.txt --single-version-externally-managed --compile --install-headers /home/wazd/.local/share/virtualenvs/fwdev-TAVasR-s/include/site/python3.7/psycopg2:
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/__init__.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/compat.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/_ipaddress.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/_range.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/pool.py -> build/lib.linux-x86_64-3.7/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.7/psycopg2
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/psycopg
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.2 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100007 -DHAVE_LO64=1 -I/usr/include/python3.7m -I/home/wazd/.local/share/virtualenvs/fwdev-TAVasR-s/include/python3.7m -I. -I/usr/include/postgresql -I/usr/include/postgresql/10/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 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/wazd/.local/share/virtualenvs/fwdev-TAVasR-s/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-zw76s0g_/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-he_4xq7_/install-record.txt --single-version-externally-managed --compile --install-headers /home/wazd/.local/share/virtualenvs/fwdev-TAVasR-s/include/site/python3.7/psycopg2" failed with error code 1 in /tmp/pip-install-zw76s0g_/psycopg2/
Here is my Piplock:
(fwdev) wazd@burger:~/Projects/fwdev$ pipenv graph --reverse
click==7.0
- Flask==1.0.2 [requires: click>=5.1]
- Flask-SQLAlchemy==2.3.2 [requires: Flask>=0.10]
itsdangerous==1.1.0
- Flask==1.0.2 [requires: itsdangerous>=0.24]
- Flask-SQLAlchemy==2.3.2 [requires: Flask>=0.10]
MarkupSafe==1.1.1
- Jinja2==2.10.1 [requires: MarkupSafe>=0.23]
- Flask==1.0.2 [requires: Jinja2>=2.10]
- Flask-SQLAlchemy==2.3.2 [requires: Flask>=0.10]
Here is output from pip freeze:
(fwdev) wazd@burger:~/Projects/fwdev$ pip freeze
Click==7.0
Flask==1.0.2
Flask-SQLAlchemy==2.3.2
itsdangerous==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
psycopg2-binary==2.8.2
SQLAlchemy==1.3.3
Werkzeug==0.15.2
One thing that does work is…
pip install psycopg2-binary
I developed a python script which imports data to my Postgres DB and it works fine on my local machine but when I transferred it to the server it fails with:
Traceback (most recent call last):
File "./importer.py", line 1, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
here is the python script:
import psycopg2
import glob, os
import zipfile
import ntpath
## db connection string and objects
t_host = "localhost"
t_dbname = "*****"
t_username = "******"
t_password = "******"
t_port = 5432
t_schema = "******"
t_stageTable = "******"
## working directories
inputDir = "./incoming"
outputDir = "./processed"
## functions definition
def clearDirectory(dir):
for csvFile in glob.glob(dir+"/*.csv"):
os.remove(csvFile)
def stripQuotes(str):
return str.strip('"')
def uploadFile(file):
db_conn = psycopg2.connect(host=t_host, port=t_port, dbname=t_dbname, user=t_username, password=t_password)
db_cursor = db_conn.cursor()
f_contents = open(file, 'r')
for row in f_contents:
record = row.rstrip().split(",")
record.append('"'+ntpath.basename(file)+'"')
insert_query = "INSERT INTO ...")
#commit after the whole file is loaded
db_conn.commit()
#close connection
db_cursor.close()
db_conn.close()
def processFiles(dirIn, dirOut):
for file in glob.glob(dirIn+"/*.zip"):
#extract files
with zipfile.ZipFile(file, 'r') as zip_ref:
zip_ref.extractall(dirOut)
for file in glob.glob(dirOut+"/*.csv"):
uploadFile(file)
#move .zip files to processed folder
for file in glob.glob(dirIn+"/*.zip"):
os.replace(file, dirOut+"/"+ntpath.basename(file))
###################################
## actual processing
###################################
#clean old files first (just to be sure)
clearDirectory(outputDir)
#loop through zip files in the incoming folder
processFiles(inputDir, outputDir)
#clean again
clearDirectory(outputDir)
###################################
I tried to install the missing library psycopg2
with pip3
sudo pip3 install psycopg2
but I am getting this weird error:
Collecting psycopg2
Using cached psycopg2-2.8.6.tar.gz (383 kB)
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-80qwhbn5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-80qwhbn5/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-uwxpzq13
cwd: /tmp/pip-install-80qwhbn5/psycopg2/
Complete output (40 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.6 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120006 -DHAVE_LO64=1 -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
36 | #include <libpq-fe.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
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-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: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-80qwhbn5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-80qwhbn5/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4g11q7zi/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/psycopg2
cwd: /tmp/pip-install-80qwhbn5/psycopg2/
Complete output (40 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.6 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120006 -DHAVE_LO64=1 -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
36 | #include <libpq-fe.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
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-80qwhbn5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-80qwhbn5/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4g11q7zi/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/psycopg2 Check the logs for full command output.
never saw this before.. any idea what’s going on?
I even tried installing the psycopg2-binary .. which was successful .. but still the py script ends up with the same error -> no module ..
EDIT: @Simon Aldrich
sudo apt install libpg-dev
ends up with:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libpq-dev : Depends: libpq5 (= 12.6-0ubuntu0.20.04.1) but 13.2-1.pgdg20.04+1 is to be installed
E: Unable to correct problems, you have held broken packages.
when I tried to remove libpq5
sudo apt purge libpq5
it says:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libapache2-mod-wsgi-py3 libboost-filesystem1.71.0 libboost-thread1.71.0 libllvm10
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
libpq5* pgadmin4* pgadmin4-desktop* pgadmin4-server* pgadmin4-web* pgagent* postgresql* postgresql-12* postgresql-client-12*
postgresql-contrib*
0 upgraded, 0 newly installed, 10 to remove and 0 not upgraded.
I don’t want the pgadmin to be removed
I need psycopg2 to link my PostgreSQL to Django. I am facing the following error.
(actual) D:hariCollegeInternshipIIT Bombay Proteomics courseCovid-19 projectWeb-based databaseClone1cov-database>pip install psycopg2
Collecting psycopg2
Using cached psycopg2-2.9.1.tar.gz (379 kB)
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'C:UsersharisEnvsactualScriptspython.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\haris\AppData\Local\Temp\pip-install-gx8wls5p\psycopg2_6ef169ccd2cd4cf28536c197bc935cae\setup.py'"'"'; __file__='"'"'C:\Users\haris\AppData\Local\Temp\pip-install-gx8wls5p\psycopg2_6ef169ccd2cd4cf28536c197bc935cae\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('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:UsersharisAppDataLocalTemppip-wheel-z6s8kuzk'
cwd: C:UsersharisAppDataLocalTemppip-install-gx8wls5ppsycopg2_6ef169ccd2cd4cf28536c197bc935cae
Complete output (20 lines):
running bdist_wheel
running build
running build_py
creating build
creating buildlib.win-amd64-3.10
creating buildlib.win-amd64-3.10psycopg2
copying liberrorcodes.py -> buildlib.win-amd64-3.10psycopg2
copying liberrors.py -> buildlib.win-amd64-3.10psycopg2
copying libextensions.py -> buildlib.win-amd64-3.10psycopg2
copying libextras.py -> buildlib.win-amd64-3.10psycopg2
copying libpool.py -> buildlib.win-amd64-3.10psycopg2
copying libsql.py -> buildlib.win-amd64-3.10psycopg2
copying libtz.py -> buildlib.win-amd64-3.10psycopg2
copying lib_ipaddress.py -> buildlib.win-amd64-3.10psycopg2
copying lib_json.py -> buildlib.win-amd64-3.10psycopg2
copying lib_range.py -> buildlib.win-amd64-3.10psycopg2
copying lib__init__.py -> buildlib.win-amd64-3.10psycopg2
running build_ext
building 'psycopg2._psycopg' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
----------------------------------------
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: 'C:UsersharisEnvsactualScriptspython.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\haris\AppData\Local\Temp\pip-install-gx8wls5p\psycopg2_6ef169ccd2cd4cf28536c197bc935cae\setup.py'"'"'; __file__='"'"'C:\Users\haris\AppData\Local\Temp\pip-install-gx8wls5p\psycopg2_6ef169ccd2cd4cf28536c197bc935cae\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('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersharisAppDataLocalTemppip-record-kkvbz9wminstall-record.txt' --single-version-externally-managed --compile --install-headers 'C:UsersharisEnvsactualincludesitepython3.10psycopg2'
cwd: C:UsersharisAppDataLocalTemppip-install-gx8wls5ppsycopg2_6ef169ccd2cd4cf28536c197bc935cae
Complete output (20 lines):
running install
running build
running build_py
creating build
creating buildlib.win-amd64-3.10
creating buildlib.win-amd64-3.10psycopg2
copying liberrorcodes.py -> buildlib.win-amd64-3.10psycopg2
copying liberrors.py -> buildlib.win-amd64-3.10psycopg2
copying libextensions.py -> buildlib.win-amd64-3.10psycopg2
copying libextras.py -> buildlib.win-amd64-3.10psycopg2
copying libpool.py -> buildlib.win-amd64-3.10psycopg2
copying libsql.py -> buildlib.win-amd64-3.10psycopg2
copying libtz.py -> buildlib.win-amd64-3.10psycopg2
copying lib_ipaddress.py -> buildlib.win-amd64-3.10psycopg2
copying lib_json.py -> buildlib.win-amd64-3.10psycopg2
copying lib_range.py -> buildlib.win-amd64-3.10psycopg2
copying lib__init__.py -> buildlib.win-amd64-3.10psycopg2
running build_ext
building 'psycopg2._psycopg' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:UsersharisEnvsactualScriptspython.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\haris\AppData\Local\Temp\pip-install-gx8wls5p\psycopg2_6ef169ccd2cd4cf28536c197bc935cae\setup.py'"'"'; __file__='"'"'C:\Users\haris\AppData\Local\Temp\pip-install-gx8wls5p\psycopg2_6ef169ccd2cd4cf28536c197bc935cae\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('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:UsersharisAppDataLocalTemppip-record-kkvbz9wminstall-record.txt' --single-version-externally-managed --compile --install-headers 'C:UsersharisEnvsactualincludesitepython3.10psycopg2' Check the logs for full command output.
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the 'C:UsersharisEnvsactualScriptspython.exe -m pip install --upgrade pip' command.
(actual) D:hariCollegeInternshipIIT Bombay Proteomics courseCovid-19 projectWeb-based databaseClone1cov-database>
I have installed Visual studio with the Desktop development with C++ and included it in PATH (environment system variables). I did not include any optional tools. The included tools are-
C++ Build core Tools core feature
C++ 2019 Redistributable Update
C++ core desktop features
Should I download any MSVC files (optional)? Why am I getting the error?
I am using ubuntu 20.04 and want to install django project dependencies using requirements.txt file. The project is using python3.9. and I’ve installed python3.9 and postgresql already.
I already tried to install dependencies using pipfile, but it failed locking dependencies.
installing dependencies give this error:
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fu9m38m8/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fu9m38m8/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-rqzwqrsw
cwd: /tmp/pip-install-fu9m38m8/psycopg2/
Complete output (38 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.9.1 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120009 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
36 | #include <libpq-fe.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
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-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, django-heroku, django-hijack, six, django-modeltranslation, django-webpack-loader, et-xmlfile, python-dateutil, text-unidecode, Faker, factory-boy, mccabe, pycodestyle, pyflakes, flake8, protobuf, googleapis-common-protos, pyasn1, rsa, pyasn1-modules, google-auth, urllib3, requests, google-api-core, pyparsing, httplib2, google-auth-httplib2, uritemplate, google-api-python-client, oauthlib, requests-oauthlib, google-auth-oauthlib, google-apis-oauth-django, gunicorn, MarkupSafe, Jinja2, numpy, openpyxl, pandas, py-avataaars, python-dotenv, slackclient, XlsxWriter
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fu9m38m8/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fu9m38m8/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-m4cr1qip/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/mahdi/.local/include/python3.8/psycopg2
cwd: /tmp/pip-install-fu9m38m8/psycopg2/
Complete output (38 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/psycopg
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.9.1 (dt dec pq3 ext lo64) -DPSYCOPG_DEBUG=1 -DPG_VERSION_NUM=120009 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -I/usr/include/libxml2 -I/usr/include/mit-krb5 -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
36 | #include <libpq-fe.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
<https://www.psycopg.org/docs/install.html>).
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fu9m38m8/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fu9m38m8/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-m4cr1qip/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/mahdi/.local/include/python3.8/psycopg2 Check the logs for full command output.
c:Userspele>pip3 install psycopg2
Collecting psycopg2
Downloading psycopg2-2.6.1.tar.gz (371kB)
100% |################################| 372kB 278kB/s
Building wheels for collected packages: psycopg2
Running setup.py bdist_wheel for psycopg2 … error
Complete output from command c:userspeleappdatalocalprogramspythonpytho
n35-32python.exe -u -c “import setuptools, tokenize;__file__=’C:\Users\pele\
AppData\Local\Temp\pip-build-eoqdqjs7\psycopg2\setup.py’;exec(compile(getat
tr(tokenize, ‘open’, open)(__file__).read().replace(‘rn’, ‘n’), __file__, ‘ex
ec’))” bdist_wheel -d C:UserspeleAppDataLocalTemptmpq6hngvt4pip-wheel- –p
ython-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating buildlib.win32-3.5
creating buildlib.win32-3.5psycopg2
copying liberrorcodes.py -> buildlib.win32-3.5psycopg2
copying libextensions.py -> buildlib.win32-3.5psycopg2
copying libextras.py -> buildlib.win32-3.5psycopg2
copying libpool.py -> buildlib.win32-3.5psycopg2
copying libpsycopg1.py -> buildlib.win32-3.5psycopg2
copying libtz.py -> buildlib.win32-3.5psycopg2
copying lib_json.py -> buildlib.win32-3.5psycopg2
copying lib_range.py -> buildlib.win32-3.5psycopg2
copying lib__init__.py -> buildlib.win32-3.5psycopg2
creating buildlib.win32-3.5psycopg2tests
copying testsdbapi20.py -> buildlib.win32-3.5psycopg2tests
copying testsdbapi20_tpc.py -> buildlib.win32-3.5psycopg2tests
copying teststestconfig.py -> buildlib.win32-3.5psycopg2tests
copying teststestutils.py -> buildlib.win32-3.5psycopg2tests
copying teststest_async.py -> buildlib.win32-3.5psycopg2tests
copying teststest_bugX000.py -> buildlib.win32-3.5psycopg2tests
copying teststest_bug_gc.py -> buildlib.win32-3.5psycopg2tests
copying teststest_cancel.py -> buildlib.win32-3.5psycopg2tests
copying teststest_connection.py -> buildlib.win32-3.5psycopg2tests
copying teststest_copy.py -> buildlib.win32-3.5psycopg2tests
copying teststest_cursor.py -> buildlib.win32-3.5psycopg2tests
copying teststest_dates.py -> buildlib.win32-3.5psycopg2tests
copying teststest_extras_dictcursor.py -> buildlib.win32-3.5psycopg2tests
copying teststest_green.py -> buildlib.win32-3.5psycopg2tests
copying teststest_lobject.py -> buildlib.win32-3.5psycopg2tests
copying teststest_module.py -> buildlib.win32-3.5psycopg2tests
copying teststest_notify.py -> buildlib.win32-3.5psycopg2tests
copying teststest_psycopg2_dbapi20.py -> buildlib.win32-3.5psycopg2tests
copying teststest_quote.py -> buildlib.win32-3.5psycopg2tests
copying teststest_transaction.py -> buildlib.win32-3.5psycopg2tests
copying teststest_types_basic.py -> buildlib.win32-3.5psycopg2tests
copying teststest_types_extras.py -> buildlib.win32-3.5psycopg2tests
copying teststest_with.py -> buildlib.win32-3.5psycopg2tests
copying tests__init__.py -> buildlib.win32-3.5psycopg2tests
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_ext
building ‘psycopg2._psycopg’ extension
error: Unable to find vcvarsall.bat
—————————————-
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
Complete output from command c:userspeleappdatalocalprogramspythonpyt
hon35-32python.exe -u -c “import setuptools, tokenize;__file__=’C:\Users\pele
\AppData\Local\Temp\pip-build-eoqdqjs7\psycopg2\setup.py’;exec(compile(get
attr(tokenize, ‘open’, open)(__file__).read().replace(‘rn’, ‘n’), __file__, ‘
exec’))” install –record C:UserspeleAppDataLocalTemppip-b21c7pii-recordi
nstall-record.txt –single-version-externally-managed –compile:
running install
running build
running build_py
creating build
creating buildlib.win32-3.5
creating buildlib.win32-3.5psycopg2
copying liberrorcodes.py -> buildlib.win32-3.5psycopg2
copying libextensions.py -> buildlib.win32-3.5psycopg2
copying libextras.py -> buildlib.win32-3.5psycopg2
copying libpool.py -> buildlib.win32-3.5psycopg2
copying libpsycopg1.py -> buildlib.win32-3.5psycopg2
copying libtz.py -> buildlib.win32-3.5psycopg2
copying lib_json.py -> buildlib.win32-3.5psycopg2
copying lib_range.py -> buildlib.win32-3.5psycopg2
copying lib__init__.py -> buildlib.win32-3.5psycopg2
creating buildlib.win32-3.5psycopg2tests
copying testsdbapi20.py -> buildlib.win32-3.5psycopg2tests
copying testsdbapi20_tpc.py -> buildlib.win32-3.5psycopg2tests
copying teststestconfig.py -> buildlib.win32-3.5psycopg2tests
copying teststestutils.py -> buildlib.win32-3.5psycopg2tests
copying teststest_async.py -> buildlib.win32-3.5psycopg2tests
copying teststest_bugX000.py -> buildlib.win32-3.5psycopg2tests
copying teststest_bug_gc.py -> buildlib.win32-3.5psycopg2tests
copying teststest_cancel.py -> buildlib.win32-3.5psycopg2tests
copying teststest_connection.py -> buildlib.win32-3.5psycopg2tests
copying teststest_copy.py -> buildlib.win32-3.5psycopg2tests
copying teststest_cursor.py -> buildlib.win32-3.5psycopg2tests
copying teststest_dates.py -> buildlib.win32-3.5psycopg2tests
copying teststest_extras_dictcursor.py -> buildlib.win32-3.5psycopg2test
s
copying teststest_green.py -> buildlib.win32-3.5psycopg2tests
copying teststest_lobject.py -> buildlib.win32-3.5psycopg2tests
copying teststest_module.py -> buildlib.win32-3.5psycopg2tests
copying teststest_notify.py -> buildlib.win32-3.5psycopg2tests
copying teststest_psycopg2_dbapi20.py -> buildlib.win32-3.5psycopg2tests
copying teststest_quote.py -> buildlib.win32-3.5psycopg2tests
copying teststest_transaction.py -> buildlib.win32-3.5psycopg2tests
copying teststest_types_basic.py -> buildlib.win32-3.5psycopg2tests
copying teststest_types_extras.py -> buildlib.win32-3.5psycopg2tests
copying teststest_with.py -> buildlib.win32-3.5psycopg2tests
copying tests__init__.py -> buildlib.win32-3.5psycopg2tests
Skipping optional fixer: buffer
Skipping optional fixer: idioms
Skipping optional fixer: set_literal
Skipping optional fixer: ws_comma
running build_ext
building ‘psycopg2._psycopg’ extension
error: Unable to find vcvarsall.bat
—————————————-
Command “c:userspeleappdatalocalprogramspythonpython35-32python.exe -u —
c ”import setuptools, tokenize;__file__=’C:\Users\pele\AppData\Local\Temp\
pip-build-eoqdqjs7\psycopg2\setup.py’;exec(compile(getattr(tokenize, ‘open’, o
pen)(__file__).read().replace(‘rn’, ‘n’), __file__, ‘exec’))“ install –recor
d C:UserspeleAppDataLocalTemppip-b21c7pii-recordinstall-record.txt –sing
le-version-externally-managed –compile” failed with error code 1 in C:Userspe
leAppDataLocalTemppip-build-eoqdqjs7psycopg2
c:Userspele>
————————————————————————————-
Продолжает не работать