解决pip install psycopg2出错问题


Posted in Python onJuly 09, 2020

pip install 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: /opt/AN/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lkf6b0y5/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lkf6b0y5/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-lkf6b0y5/psycopg2/pip-egg-info
   cwd: /tmp/pip-install-lkf6b0y5/psycopg2/
 Complete output (23 lines):
 running egg_info
 creating /tmp/pip-install-lkf6b0y5/psycopg2/pip-egg-info/psycopg2.egg-info
 writing /tmp/pip-install-lkf6b0y5/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
 writing dependency_links to /tmp/pip-install-lkf6b0y5/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
 writing top-level names to /tmp/pip-install-lkf6b0y5/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
 writing manifest file '/tmp/pip-install-lkf6b0y5/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.

解决方法:

yum install postgresql postgresql-devel python-devel python3-devel

补充知识:anaconda 通过pip 安装python psycopg2

1. 【不能在cmd里install】之前一直在 cmd 里conda install psycopg2 ,pip install psycopg2,虽然提示安装成功,但是import时还是会报错提示包不存在。

2. 【在prompt里pip】正确的安装方法是,安装完成 anaconda,进入anaconda prompt,输入命令即可

pip install psycopg2

解决pip install psycopg2出错问题

3. import psycopg2 未报错,安装成功。

以上这篇解决pip install psycopg2出错问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python使用cx_Oracle模块将oracle中数据导出到csv文件的方法
May 16 Python
python 创建弹出式菜单的实现代码
Jul 11 Python
快速了解Python相对导入
Jan 12 Python
彻彻底底地理解Python中的编码问题
Oct 15 Python
python字典值排序并取出前n个key值的方法
Oct 17 Python
python进行文件对比的方法
Dec 24 Python
Python3.5 Pandas模块之DataFrame用法实例分析
Apr 23 Python
Python中新式类与经典类的区别详析
Jul 10 Python
解决Python3下map函数的显示问题
Dec 04 Python
python函数定义和调用过程详解
Feb 09 Python
PyCharm设置Ipython交互环境和宏快捷键进行数据分析图文详解
Apr 23 Python
Python中and和or如何使用
May 28 Python
利用python下载scihub成文献为PDF操作
Jul 09 #Python
Python scrapy爬取小说代码案例详解
Jul 09 #Python
使用Python实现微信拍一拍功能的思路代码
Jul 09 #Python
pytorch 多分类问题,计算百分比操作
Jul 09 #Python
详解Python 循环嵌套
Jul 09 #Python
keras分类之二分类实例(Cat and dog)
Jul 09 #Python
python中tkinter窗口位置\坐标\大小等实现示例
Jul 09 #Python
You might like
php对大文件进行读取操作的实现代码
2013/01/23 PHP
关于PHP递归算法和应用方法介绍
2013/04/15 PHP
解析php中eclipse 用空格替换 tab键
2013/06/24 PHP
php基于session锁防止阻塞请求的方法分析
2017/08/07 PHP
firefox下jQuery UI Autocomplete 1.8.*中文输入修正方法
2012/09/19 Javascript
Js中的onblur和onfocus事件应用介绍
2013/08/27 Javascript
ie8本地图片上传预览示例代码
2014/01/12 Javascript
利用Keydown事件阻止用户输入实现代码
2014/03/11 Javascript
JS实现的倒计时效果实例(2则实例)
2015/12/23 Javascript
jquery ui dialog替代confirm实例分析
2016/01/25 Javascript
JS中JSON对象和String之间的互转及处理技巧
2016/04/06 Javascript
ArtEditor富文本编辑器增加表单提交功能
2016/04/18 Javascript
jquery实现网站列表切换效果的2种方法
2016/08/12 Javascript
微信小程序实现分享朋友圈的图片功能示例
2019/01/18 Javascript
layui button 按钮弹出提示窗口,确定才进行的方法
2019/09/06 Javascript
使用Vue-cli3.0创建的项目 如何发布npm包
2019/10/10 Javascript
使用Python的Scrapy框架编写web爬虫的简单示例
2015/04/17 Python
python使用pyqt写带界面工具的示例代码
2017/10/23 Python
python绘制双柱形图代码实例
2017/12/14 Python
取numpy数组的某几行某几列方法
2018/04/03 Python
Python XML转Json之XML2Dict的使用方法
2019/01/15 Python
Win10系统下安装labelme及json文件批量转化方法
2019/07/30 Python
numpy按列连接两个维数不同的数组方式
2019/12/06 Python
python的数学算法函数及公式用法
2020/11/18 Python
data:image data url 文件转为Blob上传后端的方法
2019/07/16 HTML / CSS
英国皇家造币厂:The Royal Mint
2018/10/05 全球购物
信息管理专业推荐信
2013/10/29 职场文书
小学教师岗位职责
2013/11/25 职场文书
论文评语大全
2014/04/29 职场文书
节能环保演讲稿
2014/08/28 职场文书
2014年办公室主任工作总结
2014/11/12 职场文书
2015年宣传部个人工作总结
2015/05/14 职场文书
寻找最美乡村教师观后感
2015/06/18 职场文书
交通安全主题班会
2015/08/12 职场文书
爱国主义教育主题班会
2015/08/13 职场文书
MYSQL优化之数据表碎片整理详解
2022/04/03 MySQL