Postgres不适用于django eclipse

时间:2012-10-28 21:25:04

标签: python django eclipse postgresql

我安装了django并在eclipse下安装了pydev插件。然后我下载了postgres(1.16.0)sql工具并安装了它。以下是我的设置:

enter image description here

然后我想在django:

下配置设置文件
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2' , 
        'NAME': 'django',                   
        'USER': 'postgres',                 
        'PASSWORD': 'admin',                
        'HOST': '',        
        'PORT': '',                     
    }
}

但是当我执行syncdb时,我得到:

    backend = load_backend(db['ENGINE'])
  File "C:\Python27\lib\site-packages\django\db\utils.py", line 24, in load_backend
    return import_module('.base', backend_name)
  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
  File "C:\Python27\lib\site-packages\django\db\backends\postgresql_psycopg2\base.py", line 13, in <module>
    from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation
  File "C:\Python27\lib\site-packages\django\db\backends\postgresql_psycopg2\creation.py", line 1, in <module>
    import psycopg2.extensions
ImportError: No module named psycopg2.extensions

我做错了什么?

PS:我在win7和eclipse juno下开发

1 个答案:

答案 0 :(得分:1)

安装psycopg2

pip install psycopg2
  

Psycopg是Python编程语言中最受欢迎的PostgreSQL适配器。它的核心是完全实现Python DB API 2.0规范。