普拉多VX

人生一路,不问来时,不知归期

0%

Ubuntu 16.4 安装psycopg2 报错

参考报错提示,安装libpg-dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(tweb_env) root@Thortest:~# pip install psycopg2
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting psycopg2
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/fd/ae/98cb7a0cbb1d748ee547b058b14604bd0e9bf285a8e0cc5d148f8a8a952e/psycopg2-2.8.6.tar.gz (383 kB)
|████████████████████████████████| 383 kB 14.5 MB/s
ERROR: Command errored out with exit status 1:
command: /root/tweb_env/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-t1d0xq5b/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-t1d0xq5b/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-6rwptxzr
cwd: /tmp/pip-install-t1d0xq5b/psycopg2/
Complete output (7 lines):
running egg_info
creating /tmp/pip-pip-egg-info-6rwptxzr/psycopg2.egg-info
writing /tmp/pip-pip-egg-info-6rwptxzr/psycopg2.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-pip-egg-info-6rwptxzr/psycopg2.egg-info/dependency_links.txt
writing top-level names to /tmp/pip-pip-egg-info-6rwptxzr/psycopg2.egg-info/top_level.txt
writing manifest file '/tmp/pip-pip-egg-info-6rwptxzr/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'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方法

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
(tweb_env) root@Thortest:~# sudo apt-get install libpq-dev # 安装依赖环境
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
postgresql-doc-10
The following NEW packages will be installed:
libpq-dev
0 upgraded, 1 newly installed, 0 to remove and 50 not upgraded.
Need to get 218 kB of archives.
After this operation, 1,096 kB of additional disk space will be used.
Get:1 http://mirrors.cloud.aliyuncs.com/ubuntu bionic-updates/main amd64 libpq-dev amd64 10.14-0ubuntu0.18.04.1 [218 kB]
Fetched 218 kB in 0s (3,547 kB/s)
Selecting previously unselected package libpq-dev.
(Reading database ... 135928 files and directories currently installed.)
Preparing to unpack .../libpq-dev_10.14-0ubuntu0.18.04.1_amd64.deb ...
Unpacking libpq-dev (10.14-0ubuntu0.18.04.1) ...
Setting up libpq-dev (10.14-0ubuntu0.18.04.1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
(tweb_env) root@Thortest:~# pip install psycopg2 # 再次安装
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting psycopg2
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/fd/ae/98cb7a0cbb1d748ee547b058b14604bd0e9bf285a8e0cc5d148f8a8a952e/psycopg2-2.8.6.tar.gz (383 kB)
|████████████████████████████████| 383 kB 28.8 MB/s
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... done
Created wheel for psycopg2: filename=psycopg2-2.8.6-cp36-cp36m-linux_x86_64.whl size=420359 sha256=e4038d16f61c8bb594aae8dfc8552bb5adc1d2c08b9b5569d65713ede01a489e
Stored in directory: /root/.cache/pip/wheels/ba/11/64/92ac0a2b09f4e201ec7578bab7d35f3dbd3e07795ee1e18319
Successfully built psycopg2
Installing collected packages: psycopg2
Successfully installed psycopg2-2.8.6