MySqlDb安装错误:Python 2.6;Mac OS 10.6,已安装XAMPP

0 投票
2 回答
721 浏览
提问于 2025-04-16 20:21

我最近开始使用Mac电脑,想把我的Django应用程序搞起来。不过,我在安装MySQLDb连接器时遇到了困难。我更喜欢使用XAMPP,所以没有单独安装MySQL和Apache。我通过MacPorts执行了以下命令来安装MySQLDb:

sudo port install py26-mysql

安装过程没有任何问题。但是当我尝试运行我的Django应用程序(settings.py里包含MySQL数据库的设置)时,出现了以下错误。

    /Library/Python/2.6/site-packages/django/db/__init__.py:60: DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.'
  DeprecationWarning
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x101112310>>
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/django/core/management/commands/runserver.py", line 88, in inner_run
    self.validate(display_num_errors=True)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 243, in validate
    from django.core.management.validation import get_validation_errors
  File "/Library/Python/2.6/site-packages/django/core/management/validation.py", line 3, in <module>
    from django.contrib.contenttypes.generic import GenericForeignKey, GenericRelation
  File "/Library/Python/2.6/site-packages/django/contrib/contenttypes/generic.py", line 6, in <module>
    from django.db import connection
  File "/Library/Python/2.6/site-packages/django/db/__init__.py", line 78, in <module>
    connection = connections[DEFAULT_DB_ALIAS]
  File "/Library/Python/2.6/site-packages/django/db/utils.py", line 93, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/Library/Python/2.6/site-packages/django/db/utils.py", line 33, in load_backend
    return import_module('.base', backend_name)
  File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/base.py", line 14, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

如果有人能帮忙,我会非常感激! :)

2 个回答

0

可能是mysql-python这个库没有正确安装。

0

在Mac电脑上安装Mysql是一个比较复杂的过程。

撰写回答