No module named MySQLdb

2019-01-01 14:30发布

I am using Python version 2.5.4 and install MySQL version 5.0 and Django. Django is working fine with Python, but not MySQL. I am using it in Windows Vista.

17条回答
与风俱净
2楼-- · 2019-01-01 14:52

...and remember there is no MySQLdb for python3.x

(I know the question is about python2.x but google rates this post quite high)


EDIT: As stated in the comments, there's a MySQLdb's fork that adds Python 3 support: github.com/PyMySQL/mysqlclient-python

查看更多
一个人的天荒地老
3楼-- · 2019-01-01 14:53

mysqldb is a module for Python that doesn't come pre-installed or with Django. You can download mysqldb here.

查看更多
栀子花@的思念
4楼-- · 2019-01-01 14:53

Try this.

pip install MySQL-python
查看更多
唯独是你
5楼-- · 2019-01-01 14:54

Thanks to derevo but I think there's another good way for doing this:

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install mysql-python
  4. Read the notes specific to this package.

I think pypm is more powerful and reliable than easy_install.

查看更多
弹指情弦暗扣
6楼-- · 2019-01-01 14:55
  • Go to your project directory with cd.
  • source/bin/activate (activate your env. if not previously).
  • Run the command easy_install MySQL-python
查看更多
看风景的人
7楼-- · 2019-01-01 14:56

On OSX these commands worked for me

brew install mysql-connector-c 
pip install MySQL-python
查看更多
登录 后发表回答