django 1.8 mysql,Django 1.8:抛出ImportError:没有名为“MySQLdb”的模块

I am trying to run my Django Server with python 3.4.3 and have been scratching my head on this for a while. The commands I have tried so far, and their error messages, are:

pip3.4 install MySQLdb (No matching distribution found for mysqldb)

pip3.4 install mysql-python (ImportError: No module named 'ConfigParser')

pip3.4 install configparser

pip install ConfigParser

File "/tmp/pip-build-mcfc7tj3/ConfigParser/configparser.py", line 397

_KEYCRE = re.compile(ur"%\(([^)]+)\)s")

^

SyntaxError: invalid syntax

pip3.4 install mysqlclient

File "/tmp/pip-build-s41j0x_s/mysqlclient/setup_posix.py", line 26, in mysql_config

raise EnvironmentError("%s not found" % (mysql_config.path,))

OSError: mysql_config not found

sudo yum install python3-dev libmysqlclient-dev

No package python3-dev available.

No package libmysqlclient-dev available.

but still cannot get it installed. What should I do from here?

Notes:

Running python3.4 manage.py runserver threw

raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

解决方案

MySQLdb is not supported on Python 3.4 - you need to use an alternative driver

python-dev and mysql-dev are package names for the apt package system; which is used by debian, ubuntu and its clones/variants.

On CentOS you need the rpm-equivalent packages.

You should install mysql-devel for the MySQL development headers; you also need to have a development toolchain - the easiest way to install that is to issue sudo yum groupinstall "Development Tools".

Now, if you installed Python using yum as well, you need to install python-devel.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值