开发者

Getting Django and PostgreSQL to work

开发者 https://www.devze.com 2023-03-26 14:08 出处:网络
I am trying to get Django and PostgreSQL to work. So far I am getting the following error when I run syncdb.

I am trying to get Django and PostgreSQL to work.

So far I am getting the following error when I run syncdb.

....
django.core.exceptions.ImproperlyConfigured:
Error loading ps开发者_运维知识库ycopg2 module: No module named psycopg2

The following is my settings.py.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'mydb',                      # Or path to database file if using sqlite3.
        'USER': 'username',                  # Not used with sqlite3.
        'PASSWORD': 'pwd123',                # Not used with sqlite3.
        'HOST': 'localhost',                 # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '5432',                      # Set to empty string for default. Not used with sqlite3.
    }
}

I think I have installed psycopg2 correctly, but I am not sure (through MacPorts).

Is there a way whether I can check whether psycopg2 is installed?

This link contains the install log of psycopg2

UPDATE

I got it working with the method below, but how do I check whether psycopg2 was actually installed before? and if so how to remove it completely?


If you are using MAC, make sure psycopg2 is installed and accesible to your main python interpreter.

This is how I'd install it on a mac:

$ sudo easy_install django
$ sudo easy_install psycopg2

Then test it:

$ python
>>> import django
>>> import psycopg2

You should not get any errors.

Also, if you are using an Eclipse/PYDEV, make sure you reconfigure your interpreter after installing django and psycopg2 libraries.

0

精彩评论

暂无评论...
验证码 换一张
取 消