简体   繁体   English

ImportError:即使安装了Mysqldb,也没有名为MySQLdb的模块

[英]ImportError: No module named MySQLdb even when Mysqldb is installed

So I have Mysql installed on my Linux. 因此,我在Linux上安装了Mysql。 After that I installed mysqldb using the command sudo apt-get install python-mysqldb. 之后,我使用命令sudo apt-get install python-mysqldb安装了mysqldb。 Then when I try to import it in python I get the error "ImportError: No module named MySQLdb". 然后,当我尝试在python中导入它时,出现错误“ ImportError:没有名为MySQLdb的模块”。 I even rebooted and all. 我什至重启了所有。 I am running python 2.7. 我正在运行python 2.7。 Is there something else that I need to do before getting this to work? 要使它正常工作,我还需要做其他事情吗? Any suggestion? 有什么建议吗? Thanks in advance !! 提前致谢 !!

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

The output of pip freeze is 点冻结的输出是

Cython==0.21
DataShape==0.3.0
Flask==0.10.1
Jinja2==2.7.3
MarkupSafe==0.23
PIL==1.1.7
PyYAML==3.11
Pygments==1.6
SQLAlchemy==0.9.7
Sphinx==1.2.3
Theano==0.6.0
Werkzeug==0.9.6
XlsxWriter==0.5.7
abstract-rendering==0.5.1
argcomplete==0.8.1
astropy==0.4.2
atom==0.3.9
backports.ssl-match-hostname==3.4.0.2
beautifulsoup4==4.3.2
binstar==0.7.1
bitarray==0.8.1
blaze==0.6.3
blz==0.6.2
bokeh==0.6.1
boto==2.32.1
casuarius==1.1
cdecimal==2.3
cffi==0.8.6
chaco==4.4.1
colorama==0.3.1
conda==3.7.0
conda-build==1.8.2
configobj==5.0.6
cryptography==0.5.4
cytoolz==0.7.0
decorator==3.4.0
docutils==0.12
enable==4.3.0
enaml==0.9.8
future==0.13.1
futures==2.1.6
gensim==0.10.3
gevent==1.0.1
gevent-websocket==0.9.3
greenlet==0.4.4
grin==1.2.1
h5py==2.3.1
ipython==2.2.0
itsdangerous==0.24
jdcal==1.0
kiwisolver==0.1.3
llvmpy==0.12.7
lxml==3.4.0
matplotlib==1.4.0
mock==1.0.1
mpi4py==1.3
multipledispatch==0.4.7
networkx==1.9.1
nltk==3.0.0
nose==1.3.4
numba==0.14.0
numexpr==2.3.1
numpy==1.9.2
openpyxl==1.8.5
pandas==0.14.1
patsy==0.3.0
pep8==1.5.7
ply==3.4
psutil==2.1.1
py==1.4.25
pyOpenSSL==0.14
pycosat==0.6.1
pycparser==2.10
pycrypto==2.6.1
pycurl==7.19.5
pyface==4.4.0
pyflakes==0.8.1
pyparsing==2.0.1
pytest==2.6.3
python-dateutil==1.5
pytz==2014.7
pyzmq==14.3.1
redis==2.9.1
requests==2.4.1
rope==0.9.4
runipy==0.1.1
scikit-image==0.10.1
scikit-learn==0.15.2
scipy==0.14.0
six==1.8.0
sockjs-tornado==1.0.1
spyder==2.3.1
statsmodels==0.5.0
sympy==0.7.5
tables==3.1.1
toolz==0.7.0
tornado==4.0.2
traits==4.4.0
traitsui==4.4.0
ujson==1.33
unicodecsv==0.9.4
wsgiref==0.1.2
xlrd==0.9.3
xlwt==0.7.5

我认为您必须导入mysql python模块:

pip install MySQL-python

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM