• 安装psycopg2出错问题处理记录


    使用postgresql数据库一直都是在服务器同一台机子上,所以一向都正常,今天在其他服务器上调用,执行pip3 install psycopg2后直接暴下面错误:

    [root@slave2 ~]# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ psycopg2
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
    Collecting psycopg2
      Using cached https://pypi.tuna.tsinghua.edu.cn/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377 kB)
        ERROR: Command errored out with exit status 1:
         command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-v70fvqse/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-v70fvqse/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
    '"'"', '"'"'
    '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-v70fvqse/psycopg2/pip-egg-info
             cwd: /tmp/pip-install-v70fvqse/psycopg2/
        Complete output (23 lines):
        running egg_info
        creating /tmp/pip-install-v70fvqse/psycopg2/pip-egg-info/psycopg2.egg-info
        writing /tmp/pip-install-v70fvqse/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
        writing dependency_links to /tmp/pip-install-v70fvqse/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
        writing top-level names to /tmp/pip-install-v70fvqse/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
        writing manifest file '/tmp/pip-install-v70fvqse/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt'
        
        Error: pg_config executable not found.
        
        pg_config is required to build psycopg2 from source.  Please add the directory
        containing pg_config to the $PATH or specify the full executable path with the
        option:
        
            python setup.py build_ext --pg-config /path/to/pg_config build ...
        
        or with the pg_config option in 'setup.cfg'.
        
        If you prefer to avoid building psycopg2 from source, please install the PyPI
        'psycopg2-binary' package instead.
        
        For further information please check the 'doc/src/install.rst' file (also at
        <http://initd.org/psycopg/docs/install.html>).
        
        ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

    按错误提示,登录提示地址 http://initd.org/psycopg/docs/install.html 进行查看

    发现原来安装psycopg2需要先安装postgresql服务

    Prerequisites
    The current psycopg2 implementation supports:
    
    Python version 2.7
    Python 3 versions from 3.4 to 3.8
    PostgreSQL server versions from 7.4 to 12
    PostgreSQL client library version from 9.1

    然后按照要求安装好了ps数据库相关服务

    yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    yum install postgresql11
    yum install postgresql11-server
    yum install postgresql11-libs
    yum install postgresql11-contrib
    yum install postgresql11-devel

    安装完成后执行pip安装,还是出错,重新认真查看官网的安装要求后,发现还需要配置 pg_config 路径(这里有点奇怪,我以前在有的服务器上并没有做这个设置,安装也是正常)

    按要求在服务器上执行了下面命令:

    export PATH=/usr/pgsql-11/bin/:$PATH

    然后再执行pip安装psycopg2

    pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ psycopg2

    安装成功

    [root@slave2 bin]# export PATH=/usr/pgsql-11/bin/:$PATH
    [root@slave2 bin]# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ psycopg2
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
    Collecting psycopg2
      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377 kB)
         |████████████████████████████████| 377 kB 4.8 MB/s 
    Building wheels for collected packages: psycopg2
      Building wheel for psycopg2 (setup.py) ... done
      Created wheel for psycopg2: filename=psycopg2-2.8.4-cp37-cp37m-linux_x86_64.whl size=382831 sha256=b2d2c502b6d15be05d06f9fa0864de1e5a46874658939a329e4f08c1f68c925d
      Stored in directory: /root/.cache/pip/wheels/15/11/c5/8f06c23a46a3162b3756d2132a5c5dd4c2edb204049d59ae93
    Successfully built psycopg2
    Installing collected packages: psycopg2
    Successfully installed psycopg2-2.8.4
  • 相关阅读:
    2019左其盛好书榜,没见过更好的榜单(截至4月30日)
    3星|菲利普·科特勒《我的营销人生》:大师一生经历、成就、著作回顾
    3星|樊登《低风险创业》:创业相关的书+樊登个人创业经验
    OKR能解决996吗?德鲁克怎么看?
    《中国合伙人》背后的故事:4星|俞敏洪《我曾走在崩溃的边缘》
    3星|路江涌《共演战略画布》:PPT技巧级别的创新,缺实际分析案例
    C# 通用数据库配置界面,微软原生DLL重整合
    SoapUI、Jmeter、Postman三种接口测试工具的比较分析
    用VS制作的windows服务安装包 安装完后如何让服务自动启动
    POI使用详解
  • 原文地址:https://www.cnblogs.com/EmptyFS/p/12606331.html
Copyright © 2020-2023  润新知