pip3 install psycopg2 失败怎么办

在ubuntu 18.04上使用pip3安装psycopg2的时候通常会报如下错误:

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'

    Error: b'You need to install postgresql-server-dev-NN for building a server-side extension or libpq-dev for building a client-side application.\n'

看最后一行的错误提示,是需要其它扩展程序,根据它的提示,选择了安装libpq-dev,如下:

apt install libpq-dev

安装成功后再执行pip3 install psyconpg2即可成功安装 

你可能感兴趣的:(pip3 install psycopg2 失败怎么办)