my requirements/local.txt
cat requirements/base.txt |grep psycopg2
# like Pillow and psycopg2
psycopg2==2.7.3.2
#psycopg2==2.7.5
pip install psycopg2 error messages
pip install psycopg2==2.7.3.2
Collecting psycopg2==2.7.3.2
Using cached psycopg2-2.7.3.2.tar.gz (425 kB)
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/administrator/D/neo/.ve/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-toh63sp5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-toh63sp5/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-c1y2hug1
cwd: /tmp/pip-install-toh63sp5/psycopg2/
Complete output (62 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/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.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/psycopg1.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/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
creating build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_connection.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_sql.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_async_keyword.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_replication.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_module.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_fast_executemany.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
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
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_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.7.3.2 (dt dec pq3 ext lo64)" -DPG_VERSION_NUM=120200 -DHAVE_LO64=1 -I/home/administrator/D/neo/.ve/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
psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
psycopg/psycopgmodule.c:685:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
685 | while (interp->next)
| ^~
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: /home/administrator/D/neo/.ve/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-toh63sp5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-toh63sp5/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-e0e08klq/install-record.txt --single-version-externally-managed --compile --install-headers /home/administrator/D/neo/.ve/include/site/python3.8/psycopg2
cwd: /tmp/pip-install-toh63sp5/psycopg2/
Complete output (62 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/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
copying lib/extras.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/psycopg1.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/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
creating build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_green.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_connection.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/testconfig.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_lobject.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_sql.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_async_keyword.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_cursor.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/testutils.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_errcodes.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/dbapi20.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_psycopg2_dbapi20.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_notify.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_replication.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_extras_dictcursor.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_types_basic.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_cancel.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_quote.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_dates.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_copy.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_async.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_transaction.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_types_extras.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_with.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_module.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
copying tests/test_fast_executemany.py -> build/lib.linux-x86_64-3.8/psycopg2/tests
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
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_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.7.3.2 (dt dec pq3 ext lo64)" -DPG_VERSION_NUM=120200 -DHAVE_LO64=1 -I/home/administrator/D/neo/.ve/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
psycopg/psycopgmodule.c: In function ‘psyco_is_main_interp’:
psycopg/psycopgmodule.c:685:18: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
685 | while (interp->next)
| ^~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/administrator/D/neo/.ve/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-toh63sp5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-toh63sp5/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-e0e08klq/install-record.txt --single-version-externally-managed --compile --install-headers /home/administrator/D/neo/.ve/include/site/python3.8/psycopg2 Check the logs for full command output.
I could install with psycopg2 version >= 2.8.0
but with 2.7.x , pip install will generate those error messages.
is that mean psycopg2 2.7.x can not work with python 3.8 in ubuntu 20.04 ?
Содержание
- Как установить psycopg2?
- Pip3 install psycopg2 error
- ModuleNotFoundError: No module named ‘psycopg2’ in Python #
- Conclusion #
- Psycopg 2.9.5 documentation
- Quick Install¶
- psycopg vs psycopg-binary¶
- Change in binary packages between Psycopg 2.7 and 2.8¶
- Prerequisites¶
- Build prerequisites¶
- Runtime requirements¶
- Non-standard builds¶
- Creating a debug build¶
- Non-standard Python Implementation¶
- Running the test suite¶
- If you still have problems¶
- Почему не устанавливается psycopg2 в виртуальное окружение?
Как установить psycopg2?
Несколько дней пытаюсь решить проблему — не получается.
UPD: решил с помощью команды
- Вопрос задан более трёх лет назад
- 27053 просмотра
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext —pg-config /path/to/pg_config build .
Вроде прямым текстом говорят — корректный путь к постгресу в PATH надо добавить. Либо указанным способом, либо
pip install psycopg2
Здравствуйте.
Лог ошибки читал, пытался пропатчить на что возвращалось
usage: sudo -h | -K | -k | -L | -V
usage: sudo -v [-AknS] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U user name] [-u user name|#uid] [-g
groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g
groupname|#gid] [VAR=value] [-i|-s] []
usage: sudo -e [-AknS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file .
Пытался вставить -e, не получалось и забросил этот способ
С sudo не дружу ещё, недавно освоил bash
Источник
Pip3 install psycopg2 error
Reading time В· 5 min
ModuleNotFoundError: No module named ‘psycopg2’ in Python #
The Python «ModuleNotFoundError: No module named ‘psycopg2′» occurs when we forget to install the psycopg2-binary module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install psycopg2-binary command.
Open your terminal in your project’s root directory and install the psycopg2-binary module.
The psycopg2-binary module is a stand-alone package that doesn’t require a compiler or external libraries.
After you install the psycopg2-binary package, try importing it as follows.
The Python error «ModuleNotFoundError: No module named ‘psycopg2′» occurs for multiple reasons:
- Not having the psycopg2-binary package installed by running pip install psycopg2-binary .
- Installing the package in a different Python version than the one you’re using.
- Installing the package globally and not in your virtual environment.
- Your IDE running an incorrect version of Python.
- Naming your module psycopg2.py which would shadow the official module.
- Declaring a variable named psycopg2 which would shadow the imported variable.
If the error persists, get your Python version and make sure you are installing the package using the correct Python version.
For example, my Python version is 3.10.4 , so I would install the psycopg2-binary package with pip3.10 install psycopg2-binary .
Notice that the version number corresponds to the version of pip I’m using.
If the PATH for pip is not set up on your machine, replace pip with python3 -m pip :
If the «No module named ‘psycopg2′» error persists, try restarting your IDE and development server/script.
You can check if you have the psycopg2-binary package installed by running the pip show psycopg2-binary command.
The pip show psycopg2-binary command will either state that the package is not installed or show a bunch of information about the package, including the location where the package is installed.
If the package is not installed, make sure your IDE is using the correct version of Python.
For example, In VSCode, you can press CTRL + Shift + P or ( вЊ + Shift + P on Mac) to open the command palette.
Then type «Python select interpreter» in the field.
Then select the correct python version from the dropdown menu.
If you are using a virtual environment, make sure you are installing psycopg2-binary in your virtual environment and not globally.
You can try creating a virtual environment if you don’t already have one.
If the python3 -m venv venv command doesn’t work, try the following 2 commands:
- python -m venv venv
- py -m venv venv
Your virtual environment will use the version of Python that was used to create it.
You also shouldn’t be declaring a variable named psycopg2 as that would also shadow the original module.
If the error is not resolved, try to uninstall the psycopg2-binary package and then install it.
Try restarting your IDE and development server/script.
You can also try to upgrade the version of the psycopg2-binary package.
This one is for using virtual environments (VENV) on Windows :
This one is for using virtual environments (VENV) on MacOS and Linux :
Conclusion #
The Python «ModuleNotFoundError: No module named ‘psycopg2′» occurs when we forget to install the psycopg2-binary module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install psycopg2-binary command.
Источник
Psycopg 2.9.5 documentation
Psycopg is a PostgreSQL adapter for the Python programming language. It is a wrapper for the libpq, the official PostgreSQL client library.
Quick Install¶
For most operating systems, the quickest way to install Psycopg is using the wheel package available on PyPI:
This will install a pre-compiled binary version of the module which does not require the build or runtime prerequisites described below. Make sure to use an up-to-date version of pip (you can upgrade it using something like pip install -U pip ).
You may then import the psycopg2 package, as usual:
psycopg vs psycopg-binary¶
The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements.
If you are the maintainer of a published package depending on psycopg2 you shouldn’t use psycopg2-binary as a module dependency. For production use you are advised to use the source distribution.
The binary packages come with their own versions of a few C libraries, among which libpq and libssl , which will be used regardless of other libraries available on the client: upgrading the system libraries will not upgrade the libraries used by psycopg2 . Please build psycopg2 from source if you want to maintain binary upgradeability.
The psycopg2 wheel package comes packaged, among the others, with its own libssl binary. This may create conflicts with other extension modules binding with libssl as well, for instance with the Python ssl module: in some cases, under concurrency, the interaction between the two libraries may result in a segfault. In case of doubts you are advised to use a package built from source.
Change in binary packages between Psycopg 2.7 and 2.8¶
In version 2.7.x, pip install psycopg2 would have tried to install automatically the binary package of Psycopg. Because of concurrency problems binary packages have displayed, psycopg2-binary has become a separate package, and from 2.8 it has become the only way to install the binary package.
If you are using Psycopg 2.7 and you want to disable the use of wheel binary packages, relying on the system libraries available on your client, you can use the pip —no-binary option, e.g.:
which can be specified in your requirements.txt files too, e.g. use:
to use the last bugfix release of the psycopg2 2.7 package, specifying to always compile it from source. Of course in this case you will have to meet the build prerequisites .
Prerequisites¶
The current psycopg2 implementation supports:
Python versions from 3.6 to 3.11
PostgreSQL server versions from 7.4 to 15
PostgreSQL client library version from 9.1
Not all the psycopg2 versions support all the supported Python versions.
Please see the release notes to verify when the support for a new Python version was added and when the support for an old Python version was removed.
Build prerequisites¶
The build prerequisites are to be met in order to install Psycopg from source code, from a source distribution package, GitHub or from PyPI.
Psycopg is a C wrapper around the libpq PostgreSQL client library. To install it from sources you will need:
The Python header files. They are usually installed in a package such as python-dev or python3-dev. A message such as error: Python.h: No such file or directory is an indication that the Python headers are missing.
The libpq header files. They are usually installed in a package such as libpq-dev. If you get an error: libpq-fe.h: No such file or directory you are missing them.
The pg_config program: it is usually installed by the libpq-dev package but sometimes it is not in a PATH directory. Having it in the PATH greatly streamlines the installation, so try running pg_config —version : if it returns an error or an unexpected version number then locate the directory containing the pg_config shipped with the right libpq version (usually /usr/lib/postgresql/X.Y/bin/ ) and add it to the PATH :
You only need pg_config to compile psycopg2 , not for its regular usage.
Once everything is in place it’s just a matter of running the standard:
or, from the directory containing the source code:
Runtime requirements¶
Unless you compile psycopg2 as a static library, or you install it from a self-contained wheel package, it will need the libpq library at runtime (usually distributed in a libpq.so or libpq.dll file). psycopg2 relies on the host OS to find the library if the library is installed in a standard location there is usually no problem; if the library is in a non-standard location you will have to tell Psycopg how to find it, which is OS-dependent (for instance setting a suitable LD_LIBRARY_PATH on Linux).
The libpq header files used to compile psycopg2 should match the version of the library linked at runtime. If you get errors about missing or mismatching libraries when importing psycopg2 check (e.g. using ldd) if the module psycopg2/_psycopg.so is linked to the right libpq.so .
Whatever version of libpq psycopg2 is compiled with, it will be possible to connect to PostgreSQL servers of any supported version: just install the most recent libpq version or the most practical, without trying to match it to the version of the PostgreSQL server you will have to connect to.
Non-standard builds¶
If you have less standard requirements such as:
using pg_config not in the PATH ,
then take a look at the setup.cfg file.
Some of the options available in setup.cfg are also available as command line arguments of the build_ext sub-command. For instance you can specify an alternate pg_config location using:
Use python setup.py build_ext —help to get a list of the options supported.
Creating a debug build¶
In case of problems, Psycopg can be configured to emit detailed debug messages, which can be very useful for diagnostics and to report a bug. In order to create a debug package:
Download and unpack the Psycopg source package (the .tar.gz package).
Edit the setup.cfg file adding the PSYCOPG_DEBUG flag to the define option.
Set the PSYCOPG_DEBUG environment variable:
Run your program (making sure that the psycopg2 package imported is the one you just compiled and not e.g. the system one): you will have a copious stream of informations printed on stderr.
Non-standard Python Implementation¶
The psycopg2 package is the current mature implementation of the adapter: it is a C extension and as such it is only compatible with CPython. If you want to use Psycopg on a different Python implementation (PyPy, Jython, IronPython) there is a couple of alternative:
a Ctypes port, but it is not as mature as the C implementation yet and it is not as feature-complete;
a CFFI port which is currently more used and reported more efficient on PyPy, but please be careful of its version numbers because they are not aligned to the official psycopg2 ones and some features may differ.
Running the test suite¶
Once psycopg2 is installed you can run the test suite to verify it is working correctly. From the source directory, you can run:
The tests run against a database called psycopg2_test on UNIX socket and the standard port. You can configure a different database to run the test by setting the environment variables:
The database should already exist before running the tests.
If you still have problems¶
Try the following. In order:
Google for psycopg2 your error message. Especially useful the week after the release of a new OS X version.
If you think that you have discovered a bug, test failure or missing feature please raise a ticket in the bug tracker.
Complain on your blog or on Twitter that psycopg2 is the worst package ever and about the quality time you have wasted figuring out the correct ARCHFLAGS . Especially useful from the Starbucks near you.
Источник
Почему не устанавливается psycopg2 в виртуальное окружение?
Установил вчера свой первый linux-дистрибутив, ubuntu20.04 и захотел запустить свои проекты.
Дальше активировал виртуальное окружение и попытался установить requirements. Возникла ошибка с distutils, которая решилась через что-то типа
sudo apt install python3.10-distutils
Вот requirements. Всё установилось, кроме psycopg2.
Когда пишу
pip install psycopg2==2.9.1
ИЛИ
pip install psycopg2-binary
Я ловлю ошибку:
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
).
error: command ‘/usr/bin/x86_64-linux-gnu-gcc’ failed with exit code 1
—————————————-
ERROR: Failed building wheel for psycopg2-binary
Running setup.py clean for psycopg2-binary
Failed to build psycopg2-binary
Installing collected packages: psycopg2-binary
Running setup.py install for psycopg2-binary . error
ERROR: Command errored out with exit status 1:
command: /home/ilya/PycharmProjects/ITAPractice/venv/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘»‘»‘/tmp/pip-install-7x74j9ki/psycopg2-binary_df21b24910fc4e6da5ddbbf26d49d050/setup.py’»‘»‘; __file__=’»‘»‘/tmp/pip-install-7x74j9ki/psycopg2-binary_df21b24910fc4e6da5ddbbf26d49d050/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 /tmp/pip-record-oq7d3194/install-record.txt —single-version-externally-managed —compile —install-headers /home/ilya/PycharmProjects/ITAPractice/venv/include/site/python3.10/psycopg2-binary
cwd: /tmp/pip-install-7x74j9ki/psycopg2-binary_df21b24910fc4e6da5ddbbf26d49d050/
Complete output (38 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.10
creating build/lib.linux-x86_64-3.10/psycopg2
copying lib/errors.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/_json.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/_range.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/extras.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/errorcodes.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/pool.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/__init__.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/extensions.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/sql.py -> build/lib.linux-x86_64-3.10/psycopg2
copying lib/tz.py -> build/lib.linux-x86_64-3.10/psycopg2
running build_ext
building ‘psycopg2._psycopg’ extension
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/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 -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=140000 -DHAVE_LO64=1 -DPSYCOPG_DEBUG=1 -I/home/ilya/PycharmProjects/ITAPractice/venv/include -I/usr/include/python3.10 -I. -I/usr/include/postgresql -I/usr/include/postgresql/14/server -I/usr/include/libxml2 -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-3.10/psycopg/adapter_asis.o -Wdeclaration-after-statement
In file included from psycopg/adapter_asis.c:28:
./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: Нет такого файла или каталога
36 | #include
| ^
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
).
error: command ‘/usr/bin/x86_64-linux-gnu-gcc’ failed with exit code 1
—————————————-
ERROR: Command errored out with exit status 1: /home/ilya/PycharmProjects/ITAPractice/venv/bin/python -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘»‘»‘/tmp/pip-install-7x74j9ki/psycopg2-binary_df21b24910fc4e6da5ddbbf26d49d050/setup.py’»‘»‘; __file__=’»‘»‘/tmp/pip-install-7x74j9ki/psycopg2-binary_df21b24910fc4e6da5ddbbf26d49d050/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 /tmp/pip-record-oq7d3194/install-record.txt —single-version-externally-managed —compile —install-headers /home/ilya/PycharmProjects/ITAPractice/venv/include/site/python3.10/psycopg2-binary Check the logs for full command output.
Очевидно, я гуглил строчку error: command ‘/usr/bin/x86_64-linux-gnu-gcc’ failed with exit code 1
и нашёл вот этот сайт.
Все команды оттуда ввёл, не помогло.
Источник
Очередная шпаргалка из коллекции проблемных для pip пакетов. На этот раз, речь пойдёт об установке с помощью pip psycopg2 — драйвера для работы с БД postgresql. Список необходимых дополнительных библиотек под катом.
Установка
Предполагается что pip (и по желанию virtualenv) у вас уже установлены и активированы. Для успешной установки psycopg2 необходимо также установить следующие пакеты (на примере ubuntu):
sudo apt—get install python—dev postgresql—server—dev—all |
После этого на моей ubuntu удалось без проблем выполнить «pip install psycopg2».
Признаки отсутствующих пакетов
При попытке установить psycopg2 через pip на чистую систему вы увидите примерно следующее:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
Downloading/unpacking psycopg2==2.4.6 (from —r docs/common.txt (line 23)) Downloading psycopg2—2.4.6.tar.gz (667kB): 667kB downloaded Storing download in cache at /home/lizzard/.pip_download_cache/http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpsycopg2%2Fpsycopg2—2.4.6.tar.gz Running setup.py egg_info for package psycopg2 Error: pg_config executable not found. Please add the directory containing pg_config to the PATH or specify the full executable path with the option: python setup.py build_ext —pg—config /path/to/pg_config build ... or with the pg_config option in ‘setup.cfg’. Complete output from command python setup.py egg_info: running egg_info creating pip—egg—info/psycopg2.egg—info writing pip—egg—info/psycopg2.egg—info/PKG—INFO writing top—level names to pip—egg—info/psycopg2.egg—info/top_level.txt writing dependency_links to pip—egg—info/psycopg2.egg—info/dependency_links.txt writing manifest file ‘pip-egg-info/psycopg2.egg-info/SOURCES.txt’ warning: manifest_maker: standard file ‘-c’ not found Error: pg_config executable not found. Please add the directory containing pg_config to the PATH or specify the full executable path with the option: python setup.py build_ext —pg—config /path/to/pg_config build ... or with the pg_config option in ‘setup.cfg’. ———————————————————— Cleaning up... Command python setup.py egg_info failed with error code 1 in /home/lizzard/.venvs/ab—server/build/psycopg2 Storing complete log in /home/lizzard/.pip/pip.log |
View community ranking In the Top 1% of largest communities on Reddit
Unable to Install psycopg2 (Python)
root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# python3 -V Python 3.7.4 root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip install psycopg2 Traceback (most recent call last): File "/usr/lib/command-not-found", line 28, in <module> from CommandNotFound import CommandNotFound File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module> from CommandNotFound.db.db import SqliteDatabase File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip install psycopg2 Traceback (most recent call last): File "/usr/lib/command-not-found", line 28, in <module> from CommandNotFound import CommandNotFound File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module> from CommandNotFound.db.db import SqliteDatabase File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip -V Traceback (most recent call last): File "/usr/lib/command-not-found", line 28, in <module> from CommandNotFound import CommandNotFound File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module> from CommandNotFound.db.db import SqliteDatabase File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip Traceback (most recent call last): File "/usr/lib/command-not-found", line 28, in <module> from CommandNotFound import CommandNotFound File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module> from CommandNotFound.db.db import SqliteDatabase File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module> import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip3 ^Z [2]+ Stopped pip3 root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip3 -V ^Z [3]+ Stopped pip3 -V root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip3 pip install psycopg2 ^Z [4]+ Stopped pip3 pip install psycopg2 root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip3 install psycopg2 Collecting psycopg2 Downloading https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz (377kB) 100% |████████████████████████████████| 378kB 905kB/s Complete output from command python setup.py egg_info: running egg_info creating pip-egg-info/psycopg2.egg-info writing pip-egg-info/psycopg2.egg-info/PKG-INFO writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt' Error: b'You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.n' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ech8eezr/psycopg2/ root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# apt-get install libpq-dev python-dev Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: at-spi2-core fonts-dejavu-extra java-common libasound2 libasound2-data libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-etnaviv1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgif7 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice-dev libice6 liblcms2-2 libllvm8 libnspr4 libnss3 libpcsclite1 libpthread-stubs0-dev libsm-dev libsm6 libx11-dev libx11-doc libx11-xcb1 libxau-dev libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-shape0 libxcb-sync1 libxcb1-dev libxcomposite1 libxdamage1 libxdmcp-dev libxfixes3 libxft2 libxi6 libxinerama1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxt-dev libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 x11-common x11-utils x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev Use 'apt autoremove' to remove them. The following additional packages will be installed: libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev libpython2.7-minimal libpython2.7-stdlib python python-minimal python2.7 python2.7-dev python2.7-minimal Suggested packages: postgresql-doc-10 python-doc python-tk python2.7-doc binfmt-support The following NEW packages will be installed: libpq-dev libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev libpython2.7-minimal libpython2.7-stdlib python python-dev python-minimal python2.7 python2.7-dev python2.7-minimal 0 upgraded, 13 newly installed, 0 to remove and 87 not upgraded. Need to get 33.2 MB of archives. After this operation, 61.1 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libpython2.7-minimal arm64 2.7.15-4ubuntu4~18.04 [335 kB] Get:2 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 python2.7-minimal arm64 2.7.15-4ubuntu4~18.04 [1142 kB] Get:3 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 python-minimal arm64 2.7.15~rc1-1 [28.1 kB] Get:4 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libpython2.7-stdlib arm64 2.7.15-4ubuntu4~18.04 [1853 kB] Get:5 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 python2.7 arm64 2.7.15-4ubuntu4~18.04 [239 kB] Get:6 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 libpython-stdlib arm64 2.7.15~rc1-1 [7620 B] Get:7 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 python arm64 2.7.15~rc1-1 [140 kB] Get:8 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libpq-dev arm64 10.10-0ubuntu0.18.04.1 [201 kB] Get:9 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libpython2.7 arm64 2.7.15-4ubuntu4~18.04 [904 kB] Get:10 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 libpython2.7-dev arm64 2.7.15-4ubuntu4~18.04 [28.0 MB] Get:11 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 libpython-dev arm64 2.7.15~rc1-1 [7684 B] Get:12 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 python2.7-dev arm64 2.7.15-4ubuntu4~18.04 [281 kB] Get:13 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 python-dev arm64 2.7.15~rc1-1 [1252 B] Fetched 33.2 MB in 3s (10.7 MB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package libpython2.7-minimal:arm64. (Reading database ... 54843 files and directories currently installed.) Preparing to unpack .../0-libpython2.7-minimal_2.7.15-4ubuntu4~18.04_arm64.deb ... Unpacking libpython2.7-minimal:arm64 (2.7.15-4ubuntu4~18.04) ... Selecting previously unselected package python2.7-minimal. Preparing to unpack .../1-python2.7-minimal_2.7.15-4ubuntu4~18.04_arm64.deb ... Unpacking python2.7-minimal (2.7.15-4ubuntu4~18.04) ... Selecting previously unselected package python-minimal. Preparing to unpack .../2-python-minimal_2.7.15~rc1-1_arm64.deb ... Unpacking python-minimal (2.7.15~rc1-1) ... Selecting previously unselected package libpython2.7-stdlib:arm64. Preparing to unpack .../3-libpython2.7-stdlib_2.7.15-4ubuntu4~18.04_arm64.deb ... Unpacking libpython2.7-stdlib:arm64 (2.7.15-4ubuntu4~18.04) ... Selecting previously unselected package python2.7. Preparing to unpack .../4-python2.7_2.7.15-4ubuntu4~18.04_arm64.deb ... Unpacking python2.7 (2.7.15-4ubuntu4~18.04) ... Selecting previously unselected package libpython-stdlib:arm64. Preparing to unpack .../5-libpython-stdlib_2.7.15~rc1-1_arm64.deb ... Unpacking libpython-stdlib:arm64 (2.7.15~rc1-1) ... Setting up libpython2.7-minimal:arm64 (2.7.15-4ubuntu4~18.04) ... Setting up python2.7-minimal (2.7.15-4ubuntu4~18.04) ... Linking and byte-compiling packages for runtime python2.7... Setting up python-minimal (2.7.15~rc1-1) ... Selecting previously unselected package python. (Reading database ... 55591 files and directories currently installed.) Preparing to unpack .../0-python_2.7.15~rc1-1_arm64.deb ... Unpacking python (2.7.15~rc1-1) ... Selecting previously unselected package libpq-dev. Preparing to unpack .../1-libpq-dev_10.10-0ubuntu0.18.04.1_arm64.deb ... Unpacking libpq-dev (10.10-0ubuntu0.18.04.1) ... Selecting previously unselected package libpython2.7:arm64. Preparing to unpack .../2-libpython2.7_2.7.15-4ubuntu4~18.04_arm64.deb ... Unpacking libpython2.7:arm64 (2.7.15-4ubuntu4~18.04) ... Selecting previously unselected package libpython2.7-dev:arm64. Preparing to unpack .../3-libpython2.7-dev_2.7.15-4ubuntu4~18.04_arm64.deb ... Unpacking libpython2.7-dev:arm64 (2.7.15-4ubuntu4~18.04) ... Selecting previously unselected package libpython-dev:arm64. Preparing to unpack .../4-libpython-dev_2.7.15~rc1-1_arm64.deb ... Unpacking libpython-dev:arm64 (2.7.15~rc1-1) ... Selecting previously unselected package python2.7-dev. Preparing to unpack .../5-python2.7-dev_2.7.15-4ubuntu4~18.04_arm64.deb ... Unpacking python2.7-dev (2.7.15-4ubuntu4~18.04) ... Selecting previously unselected package python-dev. Preparing to unpack .../6-python-dev_2.7.15~rc1-1_arm64.deb ... Unpacking python-dev (2.7.15~rc1-1) ... Setting up libpq-dev (10.10-0ubuntu0.18.04.1) ... Processing triggers for mime-support (3.60ubuntu1) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ... Setting up libpython2.7-stdlib:arm64 (2.7.15-4ubuntu4~18.04) ... Setting up python2.7 (2.7.15-4ubuntu4~18.04) ... Setting up libpython-stdlib:arm64 (2.7.15~rc1-1) ... Setting up libpython2.7:arm64 (2.7.15-4ubuntu4~18.04) ... Setting up libpython2.7-dev:arm64 (2.7.15-4ubuntu4~18.04) ... Setting up python2.7-dev (2.7.15-4ubuntu4~18.04) ... Setting up python (2.7.15~rc1-1) ... Setting up libpython-dev:arm64 (2.7.15~rc1-1) ... Setting up python-dev (2.7.15~rc1-1) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip3 install psycopg2 Collecting psycopg2 Using cached https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz Building wheels for collected packages: psycopg2 Running setup.py bdist_wheel for psycopg2 ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pp34zz_g/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/tmpl8nm38x2pip-wheel- --python-tag cp37: running bdist_wheel running build running build_py creating build creating build/lib.linux-aarch64-3.7 creating build/lib.linux-aarch64-3.7/psycopg2 copying lib/_json.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/extras.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_lru_cache.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/errors.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_range.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/__init__.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/errorcodes.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/compat.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/pool.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_ipaddress.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/tz.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/sql.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/extensions.py -> build/lib.linux-aarch64-3.7/psycopg2 running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-aarch64-3.7 creating build/temp.linux-aarch64-3.7/psycopg aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-65064r/python3.7-3.7.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100010 -DHAVE_LO64=1 -I/usr/include/python3.7m -I. -I/usr/include/postgresql -I/usr/include/postgresql/10/server -c psycopg/psycopgmodule.c -o build/temp.linux-aarch64-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 'aarch64-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 /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pp34zz_g/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-8o7khtew-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build/lib.linux-aarch64-3.7 creating build/lib.linux-aarch64-3.7/psycopg2 copying lib/_json.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/extras.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_lru_cache.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/errors.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_range.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/__init__.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/errorcodes.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/compat.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/pool.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_ipaddress.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/tz.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/sql.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/extensions.py -> build/lib.linux-aarch64-3.7/psycopg2 running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-aarch64-3.7 creating build/temp.linux-aarch64-3.7/psycopg aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-65064r/python3.7-3.7.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100010 -DHAVE_LO64=1 -I/usr/include/python3.7m -I. -I/usr/include/postgresql -I/usr/include/postgresql/10/server -c psycopg/psycopgmodule.c -o build/temp.linux-aarch64-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 'aarch64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pp34zz_g/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-8o7khtew-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-pp34zz_g/psycopg2/ root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# apt install python3-dev Reading package lists... Done Building dependency tree Reading state information... Done python3-dev is already the newest version (3.6.7-1~18.04). python3-dev set to manually installed. The following packages were automatically installed and are no longer required: at-spi2-core fonts-dejavu-extra java-common libasound2 libasound2-data libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdrm-amdgpu1 libdrm-etnaviv1 libdrm-nouveau2 libdrm-radeon1 libfontenc1 libgif7 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice-dev libice6 liblcms2-2 libllvm8 libnspr4 libnss3 libpcsclite1 libpthread-stubs0-dev libsm-dev libsm6 libx11-dev libx11-doc libx11-xcb1 libxau-dev libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-shape0 libxcb-sync1 libxcb1-dev libxcomposite1 libxdamage1 libxdmcp-dev libxfixes3 libxft2 libxi6 libxinerama1 libxmu6 libxrandr2 libxrender1 libxshmfence1 libxt-dev libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 x11-common x11-utils x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev Use 'apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 87 not upgraded. root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip3 install psycopg2 Collecting psycopg2 Using cached https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz Building wheels for collected packages: psycopg2 Running setup.py bdist_wheel for psycopg2 ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-4rla4l6c/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/tmp3txtzvyypip-wheel- --python-tag cp37: running bdist_wheel running build running build_py creating build creating build/lib.linux-aarch64-3.7 creating build/lib.linux-aarch64-3.7/psycopg2 copying lib/_json.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/extras.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_lru_cache.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/errors.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_range.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/__init__.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/errorcodes.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/compat.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/pool.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_ipaddress.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/tz.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/sql.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/extensions.py -> build/lib.linux-aarch64-3.7/psycopg2 running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-aarch64-3.7 creating build/temp.linux-aarch64-3.7/psycopg aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-65064r/python3.7-3.7.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100010 -DHAVE_LO64=1 -I/usr/include/python3.7m -I. -I/usr/include/postgresql -I/usr/include/postgresql/10/server -c psycopg/psycopgmodule.c -o build/temp.linux-aarch64-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 'aarch64-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 /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-4rla4l6c/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-fkppou53-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build/lib.linux-aarch64-3.7 creating build/lib.linux-aarch64-3.7/psycopg2 copying lib/_json.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/extras.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_lru_cache.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/errors.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_range.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/__init__.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/errorcodes.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/compat.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/pool.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/_ipaddress.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/tz.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/sql.py -> build/lib.linux-aarch64-3.7/psycopg2 copying lib/extensions.py -> build/lib.linux-aarch64-3.7/psycopg2 running build_ext building 'psycopg2._psycopg' extension creating build/temp.linux-aarch64-3.7 creating build/temp.linux-aarch64-3.7/psycopg aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-65064r/python3.7-3.7.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.3 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=100010 -DHAVE_LO64=1 -I/usr/include/python3.7m -I. -I/usr/include/postgresql -I/usr/include/postgresql/10/server -c psycopg/psycopgmodule.c -o build/temp.linux-aarch64-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 'aarch64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-4rla4l6c/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-fkppou53-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-4rla4l6c/psycopg2/ root@gateway:/var/www/default/java/jsmpp-examples/src/main/java/org/jsmpp/examples# pip3 install python3-psycopg2 Collecting python3-psycopg2 Could not find a version that satisfies the requirement python3-psycopg2 (from versions: ) No matching distribution found for python3-psycopg2
How do I solve this?