【发布时间】:2020-03-16 11:01:00
【问题描述】:
我正在尝试安装一个需要 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.
当我进入我的项目(使用 PyCharm)repo 设置时,我可以看到 psycopg2-binary 已安装。我认为这与 PATH 有关,但我似乎无法弄清楚如何解决这个问题。
which psql: /usr/bin/psql
which pg_config: /usr/bin/pg_config
我不太愿意在环境变量中做太多事情,因为我真的不想破坏某些东西。
【问题讨论】:
-
你安装了
gcc吗? -
是的。
gcc --version: gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0 -
啊!我会取消删除。非常感谢您通知我。
-
它没有被删除。
标签: python postgresql