2

I have pip installed psycopg2, but when I try to runserver or syncdb in my Django project, it raises an error saying there is "no module named _psycopg".

EDIT: the "syncdb" command now raises: django.core.exceptions.ImproperlyConfigured: ImportError django.contrib.admin: No module named _psycopg

Thanks for your help

Mathieu K.
  • 903
  • 8
  • 27

2 Answers2

1

Make sure that you've enabled psycopg2 and not psycopg in the settings.py file:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',

And not:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg',
isedev
  • 18,848
  • 3
  • 60
  • 59
  • 1
    I use dj_database but yeah it uses psycopg2 in its schemes: SCHEMES = { 'postgres': 'django.db.backends.postgresql_psycopg2', 'postgresql': 'django.db.backends.postgresql_psycopg2', 'postgis': 'django.contrib.gis.db.backends.postgis', 'mysql': 'django.db.backends.mysql', 'mysql2': 'django.db.backends.mysql', 'sqlite': 'django.db.backends.sqlite3' } – Mathieu K. Feb 07 '13 at 18:32
1

This was solved by performing a clean reinstall of django. There was apparently some dependecies missing that the recursive pip install did not seem to be able to solve.

Mathieu K.
  • 903
  • 8
  • 27