7547
DjangoをPostageSQLと使いたいと思い設定して､migrateしたのですが､以下のエラーが出てしまいました｡

**エラー:**

```

    Traceback (most recent call last):
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\db\backends\post
    gresql_psycopg2\base.py", line 23, in <module>
    import psycopg2 as Database
    ImportError: No module named 'psycopg2'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\core\management\
    __init__.py", line 385, in execute_from_command_line
    utility.execute()
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\core\management\
    __init__.py", line 354, in execute
    django.setup()
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\__init__.py", li
    ne 21, in setup
    apps.populate(settings.INSTALLED_APPS)
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\apps\registry.py
    ", line 108, in populate
    app_config.import_models(all_models)
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\apps\config.py",
    line 202, in import_models
    self.models_module = import_module(models_module_name)
     File "C:\Users\zousan\Documents\env1\lib\importlib\__init__.py", line 109, in
    import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
    File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
    File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
    File "<frozen importlib._bootstrap>", line 1129, in _exec
    File "<frozen importlib._bootstrap>", line 1471, in exec_module
    File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\contrib\auth\mod
    els.py", line 40, in <module>
    class Permission(models.Model):
      File "C:\Users\zousan\Documents\env1\lib\site-packages\django\db\models\base.p
    y", line 122, in __new__
    new_class.add_to_class('_meta', Options(meta, **kwargs))
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\db\models\base.p
    y", line 297, in add_to_class
    value.contribute_to_class(cls, name)
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\db\models\option
    s.py", line 166, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length(
    ))
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\db\__init__.py",
    line 40, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\db\utils.py", li
    ne 242, in __getitem__
    backend = load_backend(db['ENGINE'])
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\db\utils.py", li
    ne 108, in load_backend
    return import_module('%s.base' % backend_name)
    File "C:\Users\zousan\Documents\env1\lib\importlib\__init__.py", line 109, in
    import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
    File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
    File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
    File "<frozen importlib._bootstrap>", line 1129, in _exec
    File "<frozen importlib._bootstrap>", line 1471, in exec_module
    File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
    File "C:\Users\zousan\Documents\env1\lib\site-packages\django\db\backends\post
    gresql_psycopg2\base.py", line 27, in <module>
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
     django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No m
    odule named 'psycopg2'
    
```

psycopg2 が見つかないので pip を使ってインストールを試みたのですが､以下のエラーがでてできませんでした｡

**エラー:**

```

    Could not find any downloads that satisfy the requirement pycopg2
    No distributions at all found for pycopg2
    
```

そこで､このエラーについて調べてのですが､ Unix の回答ばかりで Windows の回答が見つかりませんでした｡  
なので Windows での解決方法を教えていただけると幸いです｡

**Settings.py**

```

    import os
    from django.conf.global_settings import LANGUAGE_CODE, TIME_ZONE
    import dj_database_url
    BASE_DIR = os.path.dirname(os.path.dirname(__file__))
    
    
    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
    
    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = '@71lbdkiwo_wf!)h0og^#z022$48#7=_9ldccg^(=zb&219640'
    
    # SECURITY WARNING: don't run with debug turned on in production!
    #デバッグモードをするか判定
    DEBUG = True
    if bool(os.environ.get('LOCAL_DEV', False)):
        DEBUG = False
    
    TEMPLATE_DEBUG = True
    
    ALLOWED_HOSTS = []
    
    
    # Application definition
    
    INSTALLED_APPS = (
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'bootstrapform',
    )
    
    MIDDLEWARE_CLASSES = (
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    )
    
    ROOT_URLCONF = 'homesecurity.urls'
    
    WSGI_APPLICATION = 'homesecurity.wsgi.application'
    
    
    # Database
    # https://docs.djangoproject.com/en/1.7/ref/settings/#databases
    #データベースをどれにするか判定
    DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
    if bool(os.environ.get('LOCAL_DEV', False)):
        DATABASES = {
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),   
            }
        }
    
    # Internationalization
    # https://docs.djangoproject.com/en/1.7/topics/i18n/
    
    LANGUAGE_CODE = 'ja'
    
    TIME_ZONE = 'Asia/Tokyo'
    
    USE_I18N = True
    
    USE_L10N = True
    
    USE_TZ = True
    
    
    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/1.7/howto/static-files/
    
    STATIC_URL = '/static/'
    
```
CC BY-SA 3.0
2015-03-05T09:56:32.203
7480
2015-03-06T09:43:31.497
2015-03-05T10:48:48.093
7926
7232
question
python windows django
pycopg2がインストール出来ない｡
ウインドウズのバイナリインストーラは、こちらからダウンロードできます：

<http://www.stickpeople.com/projects/python/win-psycopg/>
CC BY-SA 3.0
2015-03-06T04:52:04.187
7530
2015-03-06T04:52:04.187
2314
7480
answer
Djangoのエラーでは `psycopg2` で、pip のエラーでは `pycopg2` となっています。  
PyPIには `pycopg`
というパッケージは登録されていないので、pipでのインストール時にパッケージ名を打ち間違えて、そのようなエラーが出ているのだと思います。

```

    pip install psycopg2
    
```

で再度試してみて下さい。
CC BY-SA 3.0
2015-03-06T09:37:20.953
7547
2015-03-06T09:43:31.497
2015-03-06T09:43:31.497
3589
3589
7480
answer