下载psycopg2源码
wget https://files.pythonhosted.org/packages/89/d6/cd8c46417e0f7a16b4b0fc321f4ab676a59250d08fce5b64921897fb07cc/psycopg2-2.9.5.tar.gz
tar zxvf psycopg2-2.9.5.tar.gz
cd psycopg2-2.9.5/
确保已经安装postgresql,并找到pg_config,
find / -name "pg_config"
#找到pg_config的路径为/usr/pgsql-15/bin/pg_config
在psycopg2-2.9.5/目录下执行
python3 setup.py build_ext --pg-config /usr/pgsql-15/bin/pg_config install
即可完成安装