8

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
Prashant Pandey
  • 221
  • 3
  • 16

4 Answers4

11

Reinstall psycopg2 and use the binary.

sudo pip uninstall psycopg2    
pip install psycopg2-binary
Kenly
  • 24,317
  • 7
  • 44
  • 60
8

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

piro
  • 13,378
  • 5
  • 34
  • 38
  • BTW there's detailed description of installation options here http://initd.org/psycopg/docs/install.html#binary-install-from-pypi – Petr Gladkikh Mar 01 '18 at 16:05
4

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.

Benjamin Hicks
  • 756
  • 3
  • 7
  • 3
    thanks for the answer ! I tried to reinstall psycopg2 earlier but ended up with same errors. But when i tried pip install psycopg2 --no-cache-dir. It works !! – Prashant Pandey Oct 27 '17 at 10:17
0

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

Community
  • 1
  • 1
ryuzakyl
  • 511
  • 8
  • 14