ERROR: Command errored out with exit status 1 安装pscopg2时出现以上错误

这个错误是在使用 pip install pscycopg2的时候出现的。html

实际的报错是如下两个: python

a. fatal error: Python.h: No such file or directory  #include <Python.h>bash

b. Error: pg_config executable not found
 code

1. 对于第一个错误是由于缺乏 python-dev的包, 根据所使用的python版本对应安装 python-dev 解决。python2安装 python-dev, python3 安装python3-dev. 以python3为例:htm

sudo apt install python3-dev

 

2. 对于第二个错误,由于缺乏 libpq-dev, 安装便可解决:blog

sudo apt-get install libpq-dev

安装完以上两个依赖之后就能够继续安装pscycopg2了ip

pip install psycopg2

 

参考连接:get

Problems compiling and installing psycopg2:pip

https://www.psycopg.org/docs/faq.html#problems-compiling-and-installing-psycopg2table

pip 安装 psycopg2 安装及错误处理

http://www.javashuo.com/article/p-bivlfgsx-gr.html