Ubuntu Pip 安装 psycopg2 错误

Ubuntu Pip 安装 psycopg2 错误

错误异常

[...]
Building wheels for collected packages: psycopg2
  Building wheel for psycopg2 (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/ubuntu/.virtualenvs/blog/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ud5yu84v/psycopg2_ebb43fbe607c414196db480068a467fe/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ud5yu84v/psycopg2_ebb43fbe607c414196db480068a467fe/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' 
[...]
In file included from psycopg/psycopgmodule.c:28:
  ./psycopg/psycopg.h:36:10: fatal error: libpq-fe.h: No such file or directory
     36 | #include <libpq-fe.h>
        |          ^~~~~~~~~~~~
  compilation terminated.
  
  It appears you are missing some prerequisite to build the package from source.
  
  You may install a binary package by installing 'psycopg2-binary' from PyPI.
  If you want to install psycopg2 from source, please install the packages
  required for the build and try again.
  
  For further information please check the 'doc/src/install.rst' file (also at
  <https://www.psycopg.org/docs/install.html>).
  
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for psycopg2
  Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2
    Running setup.py install for psycopg2 ... error
    ERROR: Command errored out with exit status 1:
     command: /home/ubuntu/.virtualenvs/blog/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ud5yu84v/psycopg2_ebb43fbe607c414196db480068a467fe/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ud5yu84v/psycopg2_ebb43fbe607c414196db480068a467fe/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-1x6hwpno/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/.virtualenvs/blog/include/site/python3.8/psycopg2
         cwd: /tmp/pip-install-ud5yu84v/psycopg2_ebb43fbe607c414196db480068a467fe/
[...]
    
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/ubuntu/.virtualenvs/blog/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ud5yu84v/psycopg2_ebb43fbe607c414196db480068a467fe/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ud5yu84v/psycopg2_ebb43fbe607c414196db480068a467fe/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-1x6hwpno/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/.virtualenvs/blog/include/site/python3.8/psycopg2 Check the logs for full command output.

安装 libpq-dev

libpq-dev 是系统包,必须用操作系统的软件包安装程序来安装

(例如 apt, yum, zypper, dnf, pacman 等)

sudo apt-get install libpq-dev

安装 psycopg2

pip install psycopg2
  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值