No module named 'mysql' code example

Example 1: ImportError: No module named mysql.connector

sudo pip install mysql-connector-python

Example 2: ModuleNotFoundError: No module named 'MySQLdb'

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

Example 3: No module named 'MySQLdb'

sudo apt-get install -y python3-mysqldb

Example 4: No module named 'mysite'

import os
    import sys
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.append(BASE_DIR)
    os.environ['DJANGO_SETTINGS_MODULE'] = 'YOURAPP.settings'
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "YOURAPP.settings")

Example 5: ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package

ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package