Fixing No module named MySQLdb in Fedora 28

Today I write about how you can fix the python error “No module named MySQLdb” in Fedora 28

Why this error occurs

This can occur when you try and run a python script that imports the module MySQLdb.

If this is not properly installed it will then display the error “No module named MySQLdb”. To resolve this you need to install the module.

Installing MySQLdb for python 2 on Fedora 28

On Fedora 28 you can install MySQLdb by entering the following command:

sudo dnf install python2-mysql

This will install the libraries needed for MySQLdb and configure MySQLdb for python2.

Note: MySQLdb is not available for python 3. If you want to use this in python 3 you will have to look for another MySQL connector library.

Once this is installed you will be able to run your python 2 scripts which import this module.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.