我已执行以下命令安装mysqldb:
apt-get install python-mysqldb
它返回了:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-mysqldb is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 381 not upgraded.
但是当我尝试使用代码运行文件时:
import MySqldb;
通过
python index.py
它返回:
Traceback (most recent call last):
File "index.py", line 1, in <module>
import MySqldb;
ImportError: No module named MySqldb
请帮忙.. ??
答案 0 :(得分:1)
该模块被称为MySQLdb
- 观察案例:
import MySQLdb
演示:
>>> import MySqldb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySqldb
>>> import MySQLdb
>>> MySQLdb.__version__
'1.2.5'