我正在为项目安装psycopg2
软件包。
pip install psycopg2
然后我收到此错误:
Collecting psycopg2
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/23/7e/93c325482c328619870b6cd09370f6dbe1148283daca65115cd63642e60f/psycopg2-2.8.2.tar.gz
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'
/home/sl/anaconda3/envs/pd36/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)
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-r7a1yqf1/psycopg2/
You are using pip version 9.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
它说我需要先安装libpq-dev
(对吗?),所以我做了
psycopg2
,
然后它给了我
sudo apt-get install libpq-dev
表示我需要安装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 (= 9.5.17-0ubuntu0.16.04.1) but 10.5-1.pgdg16.04+1 is to be installed
E: Unable to correct problems, you have held broken packages.
但是,由于我的
,我无法安装libpq5的9.5.xx版本postgresql数据库最多为10.xx,并且安装
libpq5=9.5.17-0ubuntu0.16.04.1.
会将我的数据库重新安装到9.5.xx,我不允许这样做
出现在我的数据库中。所以最后,我无法安装libpq5=9.5.xx
。
这是怎么发生的,如何正确安装psycopg2,救救我。
我尝试过psycopg2
,但仍然无法导入
apt-get install python-psycopg2
在我的项目中。
我正在使用psycopg2
,python 3.6.5
。