Search code examples
pythondjangopython-2.7django-1.4

Django: psycopg2 import error


I was having a very weird bug when trying to run migrations in my freshly installed Django app and narrowed it down to the module imports. I found out django.db.backends.postgresql_psycopg2.base wasn't being imported so I checked my pyscopg2 installation by going to the Python console and trying import psycopg2.

Indeed there was an error with this module:

from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: DLL failed: The specified module could not be found.

I tried uninstalling psycopg2 with pip and installing it again, and several different versions, but I always got the same error.

I installed win-psycopg(psycopg2-2.6.2.win-amd64-py2.7-pg9.5.3-release.exe) from here.

I am using Django 1.4.22, Python 2.7.8 64 bits and Windows 7 64 bits.


Solution

  • Just tested in my machine with this package psycopg2-2.6.2-cp27-cp27m-win_amd64.whl and it works for me:

    pip install psycopg2-2.6.2-cp27-cp27m-win_amd64.whl
    

    You can get the package from http://www.lfd.uci.edu/~gohlke/pythonlibs/