Pragnya Srinivasan
Pragnya Srinivasan

Reputation: 573

Django based on PostGreSql error while executing python manage.py runserver- "raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)"

I am creating a Django project based on PostGreSql on Windows OS.

I could successfully download Postgresql (32bits) and psycopg2. I work on a 32 bit Python2.7.9 , and my Postgresql - 9.3.7 32-bits.

  1. import psycopg2 throws NO error.
  2. I could find a psycopg2 folder in Python27\Lib\site-packages
  3. My settings.py contains the following:

    DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'testdb' , 'USER': 'postgres', 'PASSWORD': 'paggu', 'HOST': 'localhost', 'PORT': '5432', } }

But I still get the below error when I try to execute the command- python manage.py runserver or python manage.py syncdb

raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: DLL
load failed: The specified module could not be found.

I am not sure if I missed on anything.

I looked up on the other Stack Overflow posts regarding this problem but didn't seem to find any solution.

Upvotes: 4

Views: 1495

Answers (1)

Matthew Weber
Matthew Weber

Reputation: 929

You may need to actually install psycopg2. To find out run the following in a Windows command prompt:

C:\path\to\project\> python

Then:

>>> help("modules")

If psycopg2 is not in the list, do the following:

Download: psycopg2-2.6.2.win32-py2.7-pg9.5.3-release.exe from HERE, then run the following in a Windows command prompt:

C:\path\to\project> easy_install /path/to/psycopg2-2.6.2.win32-py2.7-pg9.5.3-release.exe

Upvotes: 1

Related Questions