ImportError: No module named MySQLdb even when Mysqldb is installed

2k views Asked by At

So I have Mysql installed on my Linux. After that I installed mysqldb using the command sudo apt-get install python-mysqldb. Then when I try to import it in python I get the error "ImportError: No module named MySQLdb". I even rebooted and all. I am running 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
1

There are 1 answers

1
Freelancer On

I think you have to import the mysql python module:

pip install MySQL-python