import MySQLdb as Database ModuleNotFoundError: No module named 'MySQLdb' code example

Example 1: ModuleNotFoundError: No module named 'MySQLdb'

sudo apt-get install libmysqlclient-dev
sudo apt-get install libssl-dev
pip install mysqlclient

Example 2: No module named 'MySQLdb'

sudo apt-get install -y python3-mysqldb

Example 3: import MySQLdb as Database ModuleNotFoundError: No module named 'MySQLdb'

sudo apt-get install -y python-dev libmysqlclient-dev && sudo pip install mysqlclient

Tags:

Misc Example