安装 psycopg2 的时候,需要添加 PostgreSQL 的 bin 位置到 PATH 中,否则使用 pip 安装 psycopg2 的时候会报错,因为 psycopg2 需要根据 pg_config 获取 PostgreSQL 程序和库的位置:

export PATH=$PATH:/opt/common/postgresql/bin
pip install psycopg2 -i https://pypi.douban.com/simple/

使用 pg_config 可以获取的信息例如:

(venv) [root@hostname pdf]$ pg_config --libdir
/opt/common/postgresql/lib
(venv) [root@hostname pdf]$ pg_config --bindir
/opt/common/postgresql/bin
(venv) [root@hostname pdf]$ pg_config --cc
gcc
(venv) [root@hostname pdf]$ pg_config --libs
-lpgcommon -lpgport -lpthread -lz -lreadline -lrt -lcrypt -ldl -lm

pg_config 命令的全部选项如下:

(venv) [root@hostname pdf]$ pg_config --helppg_config provides information about the installed version of PostgreSQL.Usage:pg_config [OPTION]...Options:--bindir              show location of user executables--docdir              show location of documentation files--htmldir             show location of HTML documentation files--includedir          show location of C header files of the clientinterfaces--pkgincludedir       show location of other C header files--includedir-server   show location of C header files for the server--libdir              show location of object code libraries--pkglibdir           show location of dynamically loadable modules--localedir           show location of locale support files--mandir              show location of manual pages--sharedir            show location of architecture-independent support files--sysconfdir          show location of system-wide configuration files--pgxs                show location of extension makefile--configure           show options given to "configure" script whenPostgreSQL was built--cc                  show CC value used when PostgreSQL was built--cppflags            show CPPFLAGS value used when PostgreSQL was built--cflags              show CFLAGS value used when PostgreSQL was built--cflags_sl           show CFLAGS_SL value used when PostgreSQL was built--ldflags             show LDFLAGS value used when PostgreSQL was built--ldflags_ex          show LDFLAGS_EX value used when PostgreSQL was built--ldflags_sl          show LDFLAGS_SL value used when PostgreSQL was built--libs                show LIBS value used when PostgreSQL was built--version             show the PostgreSQL version-?, --help            show this help, then exitWith no arguments, all known items are shown.Report bugs to <pgsql-bugs@postgresql.org>.

Python:安装 psycopg2相关推荐

  1. python 安装 psycopg2 报错问题处理

    今天在安装服务器环境时,使用Python  安装 psycopg2 报错如下 pip3 install psycopg2 Looking in indexes: http://mirrors.clou ...

  2. python安装psycopg2

    vim ~/.bash_profile export PATH=/Applications/Postgres.app/Contents/Versions/9.4/bin/:$PATH pip inst ...

  3. python psycopg2_如何在Python上用“pip”安装psycopg2?

    如何在Python上用"pip"安装psycopg2? 我正在使用virtualenv,我需要安装"psycopg2". 我做了以下事情:pip install ...

  4. mac安装psycopg2报错

    您可以使用以下步骤在 Mac 上的 python3.8 中下载并安装 psycopg2: 打开终端并运行以下命令: pip3 install psycopg2-binary 上面的命令将安装最新版本的 ...

  5. Python使用Psycopg2访问PostgreSQL

    本文将关注: 安装Psycopg2并使用其API访问PostgreSQL数据库 然后带您完成数据插入,数据检索,数据更新和数据删除 接下来,它将介绍事务管理,连接池和错误处理技术,以使用Postgre ...

  6. linux psycopg2,Ubuntu安装psycopg2笔记

    在Windows上和Ubuntu Linux上安装psycopg2都遇到了点小插曲,记录如下 Windows下: 1. 点击这里前往官网下载源代码 2. 解压 3. 运行python setup.py ...

  7. Mac安装psycopg2解决方法

    Mac系统下如何安装psycopg2 安装步骤 安装步骤 最近由于Window本突然出现问题,临时换Mac本来工作.之前写的一些测试项目都是基于Python的,开始以为正常的clone下来安装依赖就能 ...

  8. Python 安装 xlsx模块

    为什么80%的码农都做不了架构师?>>>    Python 安装 xlsx模块 很多时候自动化测试时测试用例是写在excel中的如何读取转换成字典是一个比较关键的问题,使用pip命 ...

  9. 笔记一:python安装和执行

    一:学习内容 python安装 python简介 python执行 二:python安装 1. 下载python,网地址:https://www.python.org/,进入地址后,点击下载downl ...

最新文章

  1. Deutsch-002-音频视频
  2. Java面试题整理,连续四年百度Java岗必问面试题
  3. 手机APP测试几个要点
  4. c语言 遍历.jpg图像,求指导,如何用c语言实现读取*.raw格式图像
  5. .net odbc连接mysql数据库,下载安装MySQL数据库ODBC驱动和配置MySQL ODBC数据源
  6. DB排行榜更新,.NET Core+MySQL成主流!
  7. Ubuntu17.04 之 systemd 设置开机启动
  8. javascript 类的创建1
  9. iOS上绘制自然的签名-b
  10. SQL Server 2005系列教学(12) 导入导出服务
  11. 手把手教你配置国内镜像源
  12. html语言中alt,html中alt是什么意思?
  13. 如何理解容器,容器化的由来?它有何优缺点?
  14. “诸神之眼”——Nmap端口扫描工具使用小手册
  15. 记2017上海谷歌开发者大会:第一天
  16. php去掉字符串带逗号前面的字符,php 怎么去掉字符串最后一个逗号
  17. 1204big.th index.php,孟加拉 郵政編碼(郵遞區號)查詢 - 郵編庫(繁體)
  18. jetty服务器使用jersey作为Restful框架
  19. Android 6.0 7.0 8.0特性变更
  20. 关于Redis配置文件不生效的问题

热门文章

  1. PB 中获取时间的方法
  2. Github学生包云服务器
  3. Hessian RMI功能介绍
  4. 关于SuperSlide插件的使用
  5. html链接找不到,在此服务器上找不到请求的URL/public_html/
  6. 什么是HTTP? HTTP和HTTPS的区别?
  7. 验证CUDA和CUDNN是否安装成功的方法
  8. 计算机工业控制高职教材,计算机工业控制技术
  9. 低档计算机配置 新闻,一台电脑配置的高低,主要看这四方面
  10. 中国信通院的星火链主链支持与以太链(测试网)交互