psycopg2 import error when ubuntu upgraded to 17.10 (from 17.04)

五迷三道 提交于 2019-12-07 01:23:07

问题


Everything was working great until I upgraded the OS to Ubuntu 17.10. Now my Django project won't run (python manage.py runserver) because psycopg2 won't import. psycopg2 is already installed with pip (nothing has changed there). To be exact this is the error:

lib/python3.5/site-packages/psycopg2/.libs/libresolv-2-c4c53def.5.so: 
symbol __res_maybe_init, version GLIBC_PRIVATE not defined in file 
libc.so.6 with link time reference

回答1:


Try reinstalling psycopg2. It looks like a dynamically linked dependency changed. The database adapters as a rule have compiled components and those are compiled against system files that can change on updates, so on major OS upgrades, you'll almost certainly have to recompile a pip installed version.




回答2:


Reinstall psycopg2 and use the binary.

sudo pip uninstall psycopg2    
pip install psycopg2-binary



回答3:


It was a problem of the wheel build tool fixed with the release of a new binary pacakge in psycopg2 2.7.3.1




回答4:


I've had the same issue. Apparently, there is a compatibility issue with glibc binaries. The following worked for me:

pip uninstall psycopg2

sudo apt-get install postgresql-server-dev-X.Y (if not already installed)

pip install --no-binary :all: psycopg2

Source: Problem loading psycopg2 with glibc 2.26



来源:https://stackoverflow.com/questions/46966278/psycopg2-import-error-when-ubuntu-upgraded-to-17-10-from-17-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!