1

我知道这方面有大约 500 万个问题,但我已经尝试了几天发布的解决方案,但仍然无法弄清楚。在 Django 终端中运行后python manage.py runserver,我收到以下消息:

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x143c290>>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run
    self.validate(display_num_errors=True)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/base.py", line 266, in validate
    num_errors = get_validation_errors(s, app)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/validation.py", line 23, in get_validation_errors
    from django.db import models, connection
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/utils.py", line 92, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/utils.py", line 24, in load_backend
    return import_module('.base', backend_name)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/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

我已经完成了正常的修复,包括site.cfg在 pythonmysql 转换器中打开文件并取消注释mysql_config = /usr/local/bin/mysql_config。在我把电脑扔到墙上之前,有人有什么最后一分钟的建议吗?

4

2 回答 2

1

看起来您并没有真正安装 Python MySQLDB。你可以通过这个从你的 Python 命令行检查它,

import _mysql
于 2012-11-16T16:56:32.137 回答
1

前几天我花了好几天试图让 Django 和 MySQL 一起玩得很好。我终于设法在本指南的帮助下对其进行了排序:

http://criticus-ua.tumblr.com/post/33260391135/setting-up-django-with-mysql-on-mac-os-x-lion

它使用了Homebrew,在我看来它是一个很棒的 OSX 包管理器

于 2012-11-17T01:19:03.290 回答