安装MYSQLdb没有错误,但我无法导入
Posted
技术标签:
【中文标题】安装MYSQLdb没有错误,但我无法导入【英文标题】:No errors installing MYSQLdb, but I can't import 【发布时间】:2014-05-14 02:30:01 【问题描述】:我正在运行 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】:应该是import MySQLdb
,而不是import MYSQLdb
。案件很重要。
【讨论】:
我真的希望你是错的,这样我才不会犯这么愚蠢的错误。谢谢。以上是关于安装MYSQLdb没有错误,但我无法导入的主要内容,如果未能解决你的问题,请参考以下文章
将 MySQLdb 安装到 virtualenv 后无法导入