pyhon导入psycopg2模块,提示undefined symbol: PQconninfo
问题描述:
pyhon导入psycopg2模块,提示undefined symbol: PQconninfo
[root@hd02 ~]# python
Python 2.7.15 (default, Apr 1 2019, 00:00:00)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>>
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-aarch64/egg/psycopg2/__init__.py", line 50, in <module>
File "build/bdist.linux-aarch64/egg/psycopg2/_psycopg.py", line 7, in <module>
File "build/bdist.linux-aarch64/egg/psycopg2/_psycopg.py", line 6, in __bootstrap__
ImportError: /root/.cache/Python-Eggs/psycopg2-2.8.3-py2.7-linux-aarch64.egg-tmp/psycopg2/_psycopg.so: undefined symbol: PQconninfo
定位过程:
1. 查询PQconninfo属于那个so文件
find -name / *.so|xargs -n 1 nm -AD |grep PQconninfo
输出结果:/lib64/libpq.so
2. ldd _psycopg.so文件,确认 /lib64/libpq.so 是否包含在如下输出中,输出如附件图
ldd /root/.cache/Python-Eggs/psycopg2-2.8.3-py2.7-linux-aarch64.egg-tmp/psycopg2/_psycopg.so
3. 发现libpq.so被链到了另外一路径下的 libpq.so
4. 执行如下命令,修改其优先链接路径
export LD_LIBRARY_PATH=/usr/lib64/
问题原因:
动态链接库路径不正确,通过设置LD_LIBRARY_PATH,使其链接正确的动态库
解决办法:
执行如下命令:
export LD_LIBRARY_PATH=/usr/lib64/
- 点赞
- 收藏
- 关注作者
评论(0)