• 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也是正常的

    1. [root@localhost ~]# pip3 install psycopg2-binary
    2. Collecting psycopg2-binary
    3. 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
    4. Downloading psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.4 kB)
    5. Downloading psycopg2_binary-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)
    6. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 2.5 MB/s eta 0:00:00
    7. Installing collected packages: psycopg2-binary
    8. Successfully installed psycopg2-binary-2.9.9
    9. [root@localhost ~]# python3
    10. Python 3.10.4 (main, Oct 8 2023, 16:03:36) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
    11. Type "help", "copyright", "credits" or "license" for more information.
    12. >>> import psycopg2
    13. >>> exit()

  • 相关阅读:
    LeetCode --- 1437. Check If All 1‘s Are at Least Length K Places Away 解题报告
    面试问我线程池?还好我早有应对
    【Axure教程】自定义显示隐藏的中继器表格
    深度学习-物体检测SSD
    Linux下find与exec结合使用的妙处
    文件包含漏洞(二)
    详解Python的pyyaml模块
    vscode远程登录ubuntu linux报错,一直输入密码问题
    阿里内部2400页的Java面试手册开源啦,突袭大厂面试?
    java: 无效的源发行版: 11解决方法
  • 原文地址:https://blog.csdn.net/chanelwtt/article/details/133804643