安装psycopg2出错问题处理记录
程序员文章站
2022-06-19 10:05:41
使用postgresql数据库一直都是在服务器同一台机子上,所以一向都正常,今天在其他服务器上调用,执行pip3 install psycopg2后直接暴下面错误: [root@slave2 ~]# pip3 install -i https://pypi.tuna.tsinghua.edu.cn/ ......
使用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('"'"'\r\n'"'"', '"'"'\n'"'"');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
推荐阅读
-
解决Ubuntu pip 安装 mysql-python包出错的问题
-
Python安装过程中常见问题处理
-
安装SQL Server 2016出错提示:需要安装oracle JRE7 更新 51(64位)或更高版本问题的解决方法
-
解决打印照片出错储空间不足无法处理此命令问题
-
iis正确安装了,但是还是无法访问,这是iis和.net安装顺序问题,记录一下
-
MySQL自动停机的问题处理实战记录
-
附加数据库时出错问题处理
-
create-react-app安装出错问题解决方法
-
iTunes遇到安装汇编Microsoft..出错的问题该怎么办?
-
在Linux系统下安装Gnuplot和Maxima来帮助处理数学问题