我知道这有大约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
我已经完成了常规修复,包括在pythonmysql转换器中打开site.cfg
文件并取消注释mysql_config = /usr/local/bin/mysql_config
。在把电脑扔到墙上之前,有没有人有任何最后的建议?
答案 0 :(得分:1)
看起来你没有安装Python MySQLDB。您可以通过此命令从Python命令行中进行检查,
import _mysql
答案 1 :(得分:1)
我花了好几天试图让Django和MySQL在一周内很好地一起玩。我终于设法在本指南的帮助下对其进行了分类:
http://criticus-ua.tumblr.com/post/33260391135/setting-up-django-with-mysql-on-mac-os-x-lion
它使用了Homebrew,我认为这是一个很棒的OSX包管理器