2

I've seen this question No module named MySQLdb and I've gone through it extensively. When executing yum install MySQL-python I get:

Package MySQL-python-1.2.3-0.3.c1.1.8.amzn1.x86_64 already installed and latest version
Nothing to do

However when attempting to execute a python script importing MySQLdb:

ImportError: No module named MySQLdb

What am I missing here? Help! This is driving me up the wall!

Community
  • 1
  • 1
deleteno5
  • 29
  • 3
  • 3
    Possible duplicate of [No module named MySQLdb](http://stackoverflow.com/questions/454854/no-module-named-mysqldb) – Jordy19 Mar 02 '17 at 19:03
  • 1
    Do you use 2 or 3? If 3, try `yum install MySQL-python3`. – linusg Mar 02 '17 at 19:05
  • check what version python you are running the script with (`sys.version`) and which version you are installing to, if you have more then one version of python installed (most people do without realizing) then just figure out how to make them use the same version. – Tadhg McDonald-Jensen Mar 02 '17 at 19:43

2 Answers2

0

I have had similar issues when using CentOS, I would ensure that you are using python3 when trying to execute your script, or the direct shell. More information would be helpful though.

0

Try this:

yum install MySQL-python -y

or follow this: https://www.tutorialspoint.com/python/python_database_access.htm

  1. wget https://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
  2. unzip MySQL-python
  3. cd MySQL-python
  4. python setup.py build && python setup.py install
oshaiken
  • 2,593
  • 1
  • 15
  • 25
  • 1
    if you see import error but the package is installed it means that python does not see it in the path. The best practice is to isolate your enviroment using virtualenv. try: 1. virtualenv venv 2. source venv/bin/activate 3. pip install MySQL-python – oshaiken Mar 02 '17 at 19:41