python pip3 安装psycopg2报错

root@edb \~\]$ pip3 install psycopg2 Defaulting to user installation because normal site-packages is not writeable Collecting psycopg2 Using cached psycopg2-2.9.3.tar.gz (380 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─\> \[1 lines of output

ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.

end of output

note: This error originates from a subprocess, and is likely not a problem with pip.

error: metadata-generation-failed

× Encountered error while generating package metadata.

╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.

hint: See above for details.

安装其它包都可以,只有在安装psycopg2的时候报错,但是pip3 install psycopg2 在其它机器是没有问题的,就说明语句没有错误,报错截图忘记保存了,大概的意思就是不是pip的问题,是包的问题。

原因:

这台安装不上的机器,已经安装了PG数据库,可能是因为这个对psycopg2的包造成了影响,需要换个包安装:psycopg2-binary,这个包安装上,测试psycopg2也是正常的

复制代码
[root@localhost ~]# pip3 install psycopg2-binary
Collecting psycopg2-binary
  Obtaining dependency information for psycopg2-binary from https://files.pythonhosted.org/packages/bc/0d/486e3fa27f39a00168abfcf14a3d8444f437f4b755cc34316da1124f293d/psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.4 kB)
Downloading psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 2.5 MB/s eta 0:00:00
Installing collected packages: psycopg2-binary
Successfully installed psycopg2-binary-2.9.9
[root@localhost ~]# python3
Python 3.10.4 (main, Oct  8 2023, 16:03:36) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> exit()
相关推荐
亦陈不染4 分钟前
c#入门详解(刘铁锰)06 - 数据持久化:TXT文本保存、序列化与反序列化(附详细源码)
开发语言·计算机视觉·c#·wpf
ceclar12325 分钟前
C++Lambda表达式
开发语言·c++·算法
智启七月32 分钟前
谷歌 Gemini 3.0 正式发布:一键生成 Web OS,编程能力碾压竞品
人工智能·python
2401_8414956433 分钟前
【强化学习】动态规划算法
人工智能·python·算法·动态规划·强化学习·策略迭代·价值迭代
二进制coder37 分钟前
深入浅出:I²C多路复用器PCA9546详解 - 解决地址冲突,扩展你的I²C总线
c语言·开发语言·单片机
测试199842 分钟前
自动化测试报告生成(Allure)
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
DKunYu1 小时前
PyTorch入门
人工智能·pytorch·python·深度学习
楼田莉子1 小时前
C++学习:C++11关于类型的处理
开发语言·c++·后端·学习
ZhengEnCi1 小时前
Python_哈希表完全指南-从字典到高效查找的 Python 编程利器
python
今天没ID2 小时前
Python 集合类型全解析:从网球赛事案例看透字符串、列表、元组、集合与字典(1)
python