zoukankan      html  css  js  c++  java
  • pip3 install psycopg2安装失败,解决办法

    https://www.cnblogs.com/daofaziran/p/12604879.html

    错误提示:

      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xr58_vty/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xr58_vty/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
    '"'"', '"'"'
    '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-45gvr08r
           cwd: /tmp/pip-install-xr58_vty/psycopg2/
      Complete output (40 lines):
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-3.8
      creating build/lib.linux-x86_64-3.8/psycopg2
      copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
      copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
      running build_ext
      building 'psycopg2._psycopg' extension
      creating build/temp.linux-x86_64-3.8
      creating build/temp.linux-x86_64-3.8/psycopg
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120004 -DHAVE_LO64=1 -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
      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: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xr58_vty/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xr58_vty/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
    '"'"', '"'"'
    '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-qwxwtt18/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/psycopg2
             cwd: /tmp/pip-install-xr58_vty/psycopg2/
        Complete output (40 lines):
        running install
        running build
        running build_py
        creating build
        creating build/lib.linux-x86_64-3.8
        creating build/lib.linux-x86_64-3.8/psycopg2
        copying lib/pool.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/errorcodes.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/extensions.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/_json.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/tz.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/_lru_cache.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/sql.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/compat.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/_range.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/errors.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/extras.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/__init__.py -> build/lib.linux-x86_64-3.8/psycopg2
        copying lib/_ipaddress.py -> build/lib.linux-x86_64-3.8/psycopg2
        running build_ext
        building 'psycopg2._psycopg' extension
        creating build/temp.linux-x86_64-3.8
        creating build/temp.linux-x86_64-3.8/psycopg
        x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSYCOPG_VERSION=2.8.5 (dt dec pq3 ext lo64) -DPG_VERSION_NUM=120004 -DHAVE_LO64=1 -I/usr/include/python3.8 -I. -I/usr/include/postgresql -I/usr/include/postgresql/12/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-3.8/psycopg/psycopgmodule.o -Wdeclaration-after-statement
        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: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xr58_vty/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xr58_vty/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
    '"'"', '"'"'
    '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-qwxwtt18/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/psycopg2 Check the logs for full command output.

    解决办法:

    sudo apt-get install python-psycopg2
    sudo apt-get install libpq-dev

    然后:

    pip3 install psycopg2
  • 相关阅读:
    Springboot在IDEA中执行,开启热部署
    java 二分法学习
    python爬虫初级--获取指定页面上的菜单名称以及链接,然后导出
    使用POI读取xlsx文件,包含对excel中自定义时间格式的处理
    Linux CentOS6.8 项目部署脚本实现
    Springboot启动源码详解
    FreeMarker基础语法,宏,引用 等
    在eclipse中启动java程序的时候,每次都会在一个未设置断点的源码里面,卡断点
    Vue学习--
    阿里的maven镜像仓库,eclipse中使用maven下载jar包的时候提升速度
  • 原文地址:https://www.cnblogs.com/wangdianchao/p/13564238.html
Copyright © 2011-2022 走看看