django Error loading MySQLdb module:No module named MySQLdb

第一步:

django链接数据库报错(在命令行运行:manage.py syncdb):

 

    Error loading MySQLdb module:No module named MySQLdb
检查setting.py中的DATABASES
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'djangodb', # Or path to database file if using sqlite3.数据库名
        'USER': 'root', # Not used with sqlite3.
        'PASSWORD': '', # Not used with sqlite3.
        'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '', # Set to empty string for default. Not used with sqlite3.
    }
}
没有错误。
之所以出错是因为Django找不到这个名为MySQLdb的模块。可在命令行python中验证。
>>>python
>>>import MySQLdb

 

报错则没有MySQLdb模块。

第二步:

安装该模块。

 

一般步骤是:

1. 安装easy_install

shell > wget http://peak.telecommunity.com/dist/ez_setup.py
shell > python ez_setup.py

会自动根据本机的py版本选择对应的egg,安装完可以看到有/usr/bin/easy_install程序了

2. 安装MySQL-python

shell > easy_install MySQL-python

第三步:

>>>python
>>>import MySQLdb

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值