问题
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