psycopg2关于undefined symbol: lo_truncate64解决方法
今天,在centos6.5下安装psycopg2,利用Python连接PostgreSQL数据库的时候,出现了一个undefined symbol: lo_truncate6的错误:
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: /mydev/pyweb/cancerdb/lib/python2.7/site-packages/psycopg2/_psycopg.so: undefined symbol: lo_truncate64
究其原因,正如 http://initd.org/psycopg/docs/faq.html 所描述:
“This means that Psycopg was compiled with lo_truncate() support (i.e. the libpq used at compile time was version >= 8.3) but at runtime an older libpq dynamic library is found. Fast-forward several years, if the message reports undefined symbol: lo_truncate64 it means that Psycopg was built with large objects 64 bits API support (i.e. the libpq used at compile time was at least 9.3) but at runtime an older libpq dynamic library is found.”
(psycopg在利用lo_truncate()编译的时候需要libpq至少要9.3以上版本,但是在编译的时候却发现了一个版本较低的libpq。)
在网上看到有不少人通过修改psycopg2安装包下的 setup.cfg ,添加PostgreSQL的 pg_config,再重新手动安装psycopg2来解决:
shenweiyan@localhost :: ~ => vi setup.cfg ....... # full path. pg_config=/usr/local/psql-/bin/pg_config # Set to to use Python datetime objects for default date/time representation. use_pydatetime= .......
尝试才发现该方法不能够从根本上解决该问题,undefined symbol: lo_truncate6的报错依然存在。
经过一番摸索,结合 psycopg2 的官方文档,后来才发现需要把PostgreSQL的 libpq.so.5 跟系统的 libpq.so.5 进行替换,再重新安装psycopg2,问题即可解决:
1、find what is the libpq dynamic library used at runtime(查找运行过程中所用的libpq动态库):
$ ldd /path/to/packages/psycopg2/_psycopg.so | grep libpq
2、You can avoid the problem by using the same version of the pg_config at install time and the libpq at runtime(替换运行过程中的libpq动态库):
root@localhost :: /usr/local/download/psycopg2- => cd /usr/lib64 root@localhost :: /usr/lib64 => root@localhost :: /usr/lib64 => /lib/libpq.so. ./
3、重新安装psycopg2,解决问题。
shenweiyan@localhost :: /mydev/pyweb/download/psycopg2- => python Python (default, Jan , ::) [GCC (Red Hat -)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import psycopg2 >>>
ok,问题解决!!!
psycopg2关于undefined symbol: lo_truncate64解决方法的更多相关文章
- Linux下Python3.5使用pyqt5.11报错 ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtCore.so: undefined symbol: PySlice_AdjustIndices 解决方法
我用的Linux自带的是Python3.5版本,运行pip3 install PyQt5, 下载的是PyQt5.11,运行PyQt5程序会报错: ImportError: /usr/local/lib ...
- [转载][jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
参考 [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法 ---------------------------------------- ...
- [jQuery1.9]Cannot read property ‘msie’ of undefined错误的解决方法
原文:[jQuery1.9]Cannot read property 'msie' of undefined错误的解决方法 $.browser在jQuery1.9里被删除了,所以项目的js代码里用到$ ...
- LaTex: Undefined citation warnings 解决方法
参考 Undefined citations LaTex: Undefined citation warnings 解决方法 在使用TexMaker编译文献的时候,出现引用参考文献的问题: Packa ...
- php中提示Undefined index的解决方法
我们经常接收表单POST过来的数据时报Undefined index错误,如下: $act=$_POST['action']; 用以上代码总是提示 Notice: Undefined index: a ...
- Z-BlogPHP 安装出现 (8) Undefined offset: 6 解决方法
有些cp面板的空间会在每个网页头部和页脚增加两个调用的文件,导致zblogPHP安装出错:(8) Undefined offset: 6 主要国外的主机中PHP配置文件两个选项auto_prepend ...
- PHP LINUX Notice: undefined $_GET完美解决方法
PHP Notice: undefined 平时用$_GET[‘xx’] 取得参数值时,如果之前不加判断在未传进参数时会出现这样的警告: PHP Notice: undefined index xxx ...
- xcode duplicate symbol _GAD_MD5 解决方法
添加了mobi的广告平台后,在Device状态打包时,出现此错误. duplicate symbol _GAD_MD5 in: 解决方法: Targets ->Build Setting 中设 ...
- Call to undefined function curl_init()解决方法
今天在使用php中的 curl 扩展时 在开启
随机推荐
- PHP读取EXCEL时写入数据乱码解决办法
第一步排除excel读取的数据是不是乱码 EXCEL读取时经常会出现乱码,而我们常用的字符集是UTF-8 ,GB2312(GBK) ,这就需要对编码进行转换,但是又不能对纯数字和英文字符转换,否则会乱 ...
- pyspider安装后,点击run,报pyhton has stop working或python已停止运行的错误
问题解决虽然只有几句话,但是背后花了一天时间,各种FQ搜索. pyspider目测只支持32位的系统,所以你下载32位的python安装就行了,然后安装pyspider运行就没有问题了,坑爹啊---- ...
- USB设备类型代码(class类型)
Base Class E0h (Wireless Controller) This base class is defined for devices that are Wireless contro ...
- T-SQL 游标
游标是面向行的,它会使开发人员变懒,懒得去想用面向集合的查询方式实现某些功能. 在性能上,游标会迟更多的内存,减少可用的并发,占用带宽,锁定资源,当然还有更多的代码量. 用一个比喻来说明为什么游标会占 ...
- javaWeb Cache技术――OSCache(转-全)
什么是osCache? 它是:http://baike.baidu.com/view/1835163.htm?fr=aladdin OSCache使用指南 一.下载安装 OSCache是一个基于web ...
- Linux删除乱码文件或者目录
Linux删除乱码文件或者目录 有时在Linux下面解压一些zip或者rar文件后会产生乱码文件或者目录,这个时候使用rm不能成功删除,需要使用一些特别的方法 来进行删除,下面是我经常使用的两种方法. ...
- 【转】 怎么刷入BOOT.IMG(刷机后开机卡在第一屏的童鞋请注意)-------不错不错
原文网址:http://bbs.gfan.com/android-3440837-1-1.html 之前呢,有好多机油问我关于刷机卡屏的问题,我解答了好多,但一一解答太费事了,在这里给大家发个贴吧.其 ...
- Impala 5、Impala 性能优化
• 执行计划 – 查询sql执行之前,先对该sql做一个分析,列出需要完成这一项查询的详细方案 – 命令:explain sql.profile 要点: • 1.SQL优化,使用之前调用执行计划 • ...
- [转]Traceroute网络排障实用指南(1)
注:本文是同事的大作,虽是翻译的一篇英文PPT,但内容实在精彩,小小的Traceroute竟包含如此大的信息量,真是让人感慨!内容不涉及公司机密,所以一直想转到自己的Blog上来,自己需要时可以再翻阅 ...
- 虚拟机下opensips 启动
先启动MYSQL mysql:service mysqld start 然后启动RTP代理 rtpproxy -l 192.168.6.199 -s udp:192.168.6.199:7890 -F ...