安装MYSQLdb没有错误,但我无法导入

时间:2014-04-02 16:34:51

标签: linux mysql-python

我正在运行Linux Mint 13和Python 2.7.3,我正在尝试安装mysqldb,但无法导入它。我跑:

sudo apt-get install build-essential python-dev libmysqlclient-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version.
libmysqlclient-dev is already the newest version.
python-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 465 not upgraded.

sudo pip install MySQL-python
Requirement already satisfied (use --upgrade to upgrade): MySQL-python in /usr/local/lib/python2.7/dist-packages
Cleaning up...

在python命令行中,我运行:

import MYSQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MYSQLdb

我也试过了:

sudo apt-get install python-mysqldb

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

应该是import MySQLdb,而不是import MYSQLdb。案件很重要。