2012-09-24 71 views
0

我正在嘗試構建我的第一個Django應用程序,但無法在初始嘗試中正確同步數據庫。Windows 7上的manage.py syncdb失敗

我得到以下錯誤:

c:\mysite>manage.py syncdb 
Traceback (most recent call last): 
    File "C:\mysite\manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 443, in execute_from_command_line 
    utility.execute() 
    File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 382, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 261, in fetch_command 
    klass = load_command_class(app_name, subcommand) 
    File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 69, in load_command_class 
    module = import_module('%s.management.commands.%s' % (app_name, 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\core\management\commands\syncdb.py", line 8, in <module> 
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal 
    File "C:\Python27\lib\site-packages\django\core\management\sql.py", line 6, in <module> 
    from django.db import models 
    File "C:\Python27\lib\site-packages\django\db\__init__.py", line 40, in <module> 
    backend = load_backend(connection.settings_dict['ENGINE']) 
    File "C:\Python27\lib\site-packages\django\db\__init__.py", line 34, in __getattr__ 
    return getattr(connections[DEFAULT_DB_ALIAS], item) 
    File "C:\Python27\lib\site-packages\django\db\utils.py", line 92, in __getitem__ 
    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 
    File "C:\Python27\lib\site-packages\psycopg2\__init__.py", line 67, in <module> 
    from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID 
ImportError: DLL load failed: %1 is not a valid Win32 application. 

我在做什麼錯?

我已經安裝了Python 2.7,Postgres 9.1.3.1,psycopg 2.4.5(匹配2.7 & 9.1.3)。

回答

2
ImportError: DLL load failed: %1 is not a valid Win32 application. 

使您的機器和Python/Postgres/psycopg的體系結構看起來不匹配。例如,如果您使用的是32位體系結構,但嘗試安裝64位代碼。

檢查this post作爲另一個有同樣問題的人的例子。這似乎可能實際上是一個python版本問題。嘗試安裝與您使用的其他版本的Python。