设置导致mysql抛出错误

时间:2014-09-11 04:38:04

标签: mysql django

我使用此命令在我的虚拟环境中安装了mysql,并且已成功安装..

sudo apt-get install libmysqlclient-dev
sudo pip install MySQL-python

现在在我的settings.py中我已经完成了这个..

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': os.path.join(BASE_DIR, 'db_hotelnepal'),
}
}

但是当我运行服务器时,它会抛出错误说""加载MySQLdb模块时出错:%s" %e) django.core.exceptions.ImproperlyConfigured:加载MySQLdb模块时出错:没有名为MySQLdb的模块"" ...

问题是什么,我该如何解决?

1 个答案:

答案 0 :(得分:0)

MySQL-python与python 3不兼容,它给出了这个错误。你没有提到你正在使用的python版本,但是我在使用python 3和MySQL时才看到这个,所以我会做出这个假设。我使用MySQL-for-Python-3,可以在这里找到:MySQL-for-Python-3。它与python 2.7-3.3兼容,还没有用MySQL和python 3.4的项目来试用它。

我通过运行pip install https://github.com/davispuh/MySQL-for-Python-3/archive/1.0.tar.gz

进行安装
相关问题