ImportError: No module named 'psycopg2._psycopg' ImportError: No module named 'psycopg2._psycopg' python-3.x python-3.x

ImportError: No module named 'psycopg2._psycopg'


Eureka! I pulled my hair out for 2 days trying to get this to work. Enlightenment came from this SO Question. Simply stated, you probably installed psycopg2 x64 version like I did, not realizing your python version was 32-bit. Unistall your current psycopg2, then:

Download: psycopg2-2.6.1.win32-py3.4-pg9.4.4-release.exe from HERE, then run the following in a Terminal:

C:\path\to\project> easy_install /path/to/psycopg2-2.6.1.win32-py3.4-pg9.4.4-release.exeC:\path\to\project> python manage.py makemigrationsC:\path\to\project> python manage.py migrate

You may also need to (re)create super user with:

C:\path\to\project> python manage.py createsuperuser


I had the same problem, solved it in this way:

Reinstall the package psycopg2 using pip (by default installed with python 3)

On Linux:

pip uninstall psycopg2

Confirm with (y) and then:

pip install psycopg2

On Windows I add the prefix ('python -m') to the commands above.I think the problem occurs when you change the version of Python. (Even between minor versions such as Python 3.5 and 3.6).


Download the compiled version of psycopg2 from this link https://github.com/jkehler/awslambda-psycopg2. As psycopg2 is C library for python, which need to be compiled on linux to make it work. The compile instruction also given on that link. Thanks to the https://github.com/jkehler.