您需要安装postgresql-server-dev-X.Y以构建服务器端扩展或安装libpq-dev以构建客户端应用程序。

11 浏览
0 Comments

您需要安装postgresql-server-dev-X.Y以构建服务器端扩展或安装libpq-dev以构建客户端应用程序。

我正在使用virtualenv在Django项目中,并将其连接到本地的postgres数据库。当我运行项目时,它显示:

ImportError: No module named psycopg2.extensions

然后我使用了以下命令进行安装:

pip install psycopg2

在安装期间,它给出以下错误:

Downloading/unpacking psycopg2==2.4.4
  Downloading psycopg2-2.4.4.tar.gz (648kB): 648kB downloaded
  Running setup.py (path:/home/muhammadtaqi/Projects/MyProjects/OnlineElectionCampaign/venv/build/psycopg2/setup.py) egg_info for package psycopg2
    Error: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
    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: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/muhammadtaqi/Projects/MyProjects/OnlineElectionCampaign/venv/build/psycopg2
Storing debug log for failure in /home/muhammadtaqi/.pip/pip.log

admin 更改状态以发布 2023年5月21日
0
0 Comments

我刚刚在终端中以 root 用户身份运行了这个命令,问题解决了,

sudo apt-get install -y postgis postgresql-9.3-postgis-2.1
pip install psycopg2

或者

sudo apt-get install libpq-dev python-dev
pip install psycopg2

0
0 Comments

使用以下命令,这将解决错误:

sudo apt-get install postgresql

然后执行:

sudo apt-get install python-psycopg2

最后:

sudo apt-get install libpq-dev

0