Python 如何将pip指向psycopg2包?
我正在尝试安装一个需要Python 如何将pip指向psycopg2包?,python,postgresql,Python,Postgresql,我正在尝试安装一个需要psycopg2作为依赖项的包,因此我使用pip install psycopg2 binary安装了psycopg2 binary,但当我尝试pip install django tenant schemas时,我遇到以下错误: In file included from psycopg/psycopgmodule.c:27:0: ./psycopg/psycopg.h:34:10: fatal error: Python.h: No such file or direc
psycopg2
作为依赖项的包,因此我使用pip install psycopg2 binary
安装了psycopg2 binary
,但当我尝试pip install django tenant schemas
时,我遇到以下错误:
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.
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
ERROR: Command errored out with exit status 1:
/home/david/PycharmProjects/clearpath/venv/bin/python -u
-c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ckbbq00w/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ckbbq00w/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-pi6j7x5l/install-record.txt
--single-version-externally-managed
--compile
--install-headers /home/david/PycharmProjects/clearpath/venv/include/site/python3.7/psycopg2 Check the logs for full command output.
psycopg/psycopgmodule.c中包含的文件中的:27:0:
./psycopg/psycopg.h:34:10:致命错误:Python.h:没有这样的文件或目录
#包括
^~~~~~~~~~
编译终止。
您可以通过从PyPI安装“psycopg2 binary”来安装二进制软件包。
如果要从源代码处安装psycopg2,请安装生成所需的软件包,然后重试。
有关更多信息,请查看“doc/src/install.rst”文件(也位于)。
错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为1
错误:命令出错,退出状态为1:
/home/david/PycharmProjects/clearpath/venv/bin/python-u
-c'导入系统、设置工具、标记化;sys.argv[0]=“”/tmp/pip-install-ckbbq00w/psycopg2/setup.py“”__文件''''/tmp/pip-install-ckbbq00w/psycopg2/setup.py''';f=getattr(标记化,“'open'”,open)(\uuuuu文件);code=f.read().replace(“\r\n”“”、“\n”“”);f、 close();exec(编译(代码,文件,exec)安装
--record/tmp/pip-record-pi6j7x5l/install-record.txt
--外部管理的单一版本
--编撰
--安装headers/home/david/PycharmProjects/clearpath/venv/include/site/python3.7/psycopg2检查日志以获得完整的命令输出。
当我进入我的项目(使用PyCharm)时,我可以看到安装了psycopg2二进制文件。我认为这与路径有关,但我似乎不知道如何解决这个问题
哪个psql
:/usr/bin/psql
哪个pg_配置
:/usr/bin/pg_配置
我不喜欢在环境变量中做太多事情,因为我真的不想破坏某些东西。您似乎试图安装pscopg2,如果已经安装了psycopg2二进制文件,可能会导致问题 以下是几行日志:
ERROR: Command errored out with exit status 1:
/home/david/PycharmProjects/clearpath/venv/bin/python -u
-c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ckbbq00w/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ckbbq00w/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-pi6j7x5l/install-record.txt
--single-version-externally-managed
--compile
--install-headers /home/david/PycharmProjects/clearpath/venv/include/site/python3.7/psycopg2 Check the logs for full command output.
我会尝试卸载psycopg2二进制文件
,然后重新安装django租户模式
问题似乎是libpq-fe-h安装不正确,通过重新安装修复了该问题。问题已解决您是否安装了
gcc
?是<代码>gcc——版本:gcc(Ubuntu 7.4.0-1ubuntu1~18.04.1)7.4.0Ahh!我将取消删除。非常感谢你通知我这件事。它还没有删除。