0

我在 Windows 7 上将 Django 与 Python 2.7 一起使用,我安装了 XAMPP 并使用其中包含的 PHPMyAdmin MySQL 创建了一个要在 Django 中使用的数据库,但是当我使用“python manage.py syncdb”命令时,我得到了这个错误:

Traceback (most recent call last):
  File "iFriends\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_comman
d
    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\mysql\base.py", line 16, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

我已经检查了主机、用户名、密码,这些都是正确的,我真的很想使用 Django,所以如果有人可以帮助我,那就太好了。

4

2 回答 2

1

您需要为 Windows 安装 mysql lib。

http://www.codegood.com/archives/4

http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

http://www.codegood.com/archives/129

于 2012-06-30T13:53:42.190 回答
0

你需要一个依赖

easy_install mysql-python
于 2012-06-30T13:50:39.537 回答