I was facing the similar issue. My env details - Python 2.7.11 pip 9.0.1 CentOS release 5.11 (Final)

Error on python interpreter -

>>> import mysql.connector
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mysql.connector
>>>

Use pip to search the available module -

 $ pip search mysql-connector | grep --color mysql-connector-python



mysql-connector-python-rf (2.2.2)        - MySQL driver written in Python
mysql-connector-python (2.0.4)           - MySQL driver written in Python

Install the mysql-connector-python-rf -

$ pip install mysql-connector-python-rf

Verify

$ python
Python 2.7.11 (default, Apr 26 2016, 13:18:56)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>>
Answer from Rishi on Stack Overflow
🌐
Reddit
reddit.com › r/mysql › python can not import mysql
r/mysql on Reddit: Python can not import mysql
June 22, 2022 - For anyone facing this issue today.. in command prompt or whatever u used to install (idk im a newbie) instead of pip install i tried pip3 install mysql-connector-python and then imported mysql.connector in python and it worked then. Earlier it wasn't as I only used pip install.
Discussions

Windows 11 - Python mysql import error
‘’’ This code was running with no issues and connecting to a remote mysql DB and not sure why it is failing now with this error. Appreciate any help as I am new to python. The ERROR Traceback (most recent call last): File “C:/PROJECTS/Python/mySQL/mySQL_Forum.py”, line 2, in from ... More on discuss.python.org
🌐 discuss.python.org
10
0
March 1, 2025
[Migrated] ModuleNotFoundError: No module named 'mysql'
Originally from: Miserlou/Zappa#1401 by jsahoo Context I'm trying to use MySQL Connector/Python with Zappa but keep getting ModuleNotFoundError: No module named 'mysql' after deploying. Everything ... More on github.com
🌐 github.com
1
February 20, 2021
ImportError: No module named 'mysql' : Forums : PythonAnywhere
Traceback (most recent call last): ...python3.4/site-packages/sqlalchemy/dialects/mysql/mysqlconnector.py", line 107, in dbapi from mysql import connector ImportError: No module named 'mysql'... More on pythonanywhere.com
🌐 pythonanywhere.com
September 5, 2016
ModuleNotFoundError: No module named 'mysql' Error
The error in your screenshot does not match your question title. Which error are you getting? More on reddit.com
🌐 r/learnpython
13
1
April 5, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › modulenotfounderror-no-module-named-mysql-in-python
Modulenotfounderror: No Module Named Mysql in Python - GeeksforGeeks
July 23, 2025 - Module Not Installed: The MySQL connector module might not be on your system, which means Python can’t find it. Incorrect Module Name: Python is case-sensitive, so even a small typo or wrong capitalization when importing the module can cause an error.
🌐
Python.org
discuss.python.org › python help
Windows 11 - Python mysql import error - Python Help - Discussions on Python.org
March 1, 2025 - ‘’’ This code was running with no issues and connecting to a remote mysql DB and not sure why it is failing now with this error. Appreciate any help as I am new to python. The ERROR Traceback (most recent call last): File “C:/PROJECTS/Python/mySQL/mySQL_Forum.py”, line 2, in from mysql.connector import Error ImportError: cannot import name ‘Error’ from ‘mysql.connector’ (unknown location) I have masked out my clients db credentials which are correct, the database server is running.
🌐
Stack Abuse
stackabuse.com › bytes › fixing-modulenotfounderror-no-module-named-mysql-in-python
Fixing "ModuleNotFoundError: No module named 'mysql'" in Python
August 14, 2023 - The ModuleNotFoundError: No module named 'mysql' error is encountered when you try to import the MySQL module in your Python script but the interpreter fails to locate it. This usually means that the MySQL module is not installed in your Python environment.
🌐
GitHub
github.com › zappa › Zappa › issues › 529
[Migrated] ModuleNotFoundError: No module named 'mysql' · Issue #529 · zappa/Zappa
February 20, 2021 - I also tried uninstalling mysql-connector-python and instead installed mysql-connector-python-rf via pip install mysql-connector-python-rf. I get the exact same issue, ModuleNotFoundError: No module named 'mysql' on Lambda (again, it works perfectly locally).
Author   zappa
Find elsewhere
🌐
PythonAnywhere
pythonanywhere.com › forums › topic › 7427
ImportError: No module named 'mysql' : Forums : PythonAnywhere
September 5, 2016 - Ah, I think I see the problem. Your code appears to be set up to use SQAlchemy with MySQLConnector instead of the normal MySQL client library. Try installing mysql-connector-python instead of mysqlclient.
🌐
PyPI
pypi.org › project › mysql-connector-python
mysql-connector-python · PyPI
To keep existing installations unchanged and the base connector lightweight, these dependencies are not installed by default. You must install them separately to use the mysql.ai features. ... This example demonstrates how to use MyLLM within a loop to create a simple chatbot that maintains conversation history. from collections import deque from mysql import connector from mysql.ai.genai import MyLLM def run_chatbot(db_connection, chat_history_size=5): # Initialize MyLLM with the database connection my_llm = MyLLM(db_connection) # Maintain a limited history for context chat_history = deque(ma
      » pip install mysql-connector-python
    
Published   Apr 23, 2026
Version   9.7.0
🌐
GitHub
github.com › orgs › community › discussions › 45772
ModuleNotFoundError: No module named 'mysql' ; the <py-config> need to fix in .html · community · Discussion #45772
import mysql.connector import webbrowser import time import pymysql mydb = mysql.connector.connect( host="196.168.16.144", user="root", password="password123", database="cloud_db", auth_plugin='mysql_native_password' ) mycursor = mydb.cursor() mycursor.execute("SELECT P_TITLE,P_DESC FROM webpage WHERE P_ID = 'en_1-01'") myresult = mycursor.fetchall() print(myresult) but run/execute in html faced ModuleNotFoundError: No module named 'mysql'
🌐
SmartTechWays
smarttechways.com › home › modulenotfounderror: no module named ‘mysql’
ModuleNotFoundError: No module named 'mysql' - SmartTechWays - Innovative Solutions for Smart Businesses
December 3, 2025 - Error: ModuleNotFoundError: No module named ‘mysql’ . While executing the Python program which uses the MySQL import statement returns the following error: Cause: PIP package for Mysql is not installed. Solution: Install the pip package for MySQL.
🌐
Medium
vatshayan.medium.com › importerror-no-module-named-mysql-fed58a5ce35c
ImportError: No module named ‘MySQL’ - Shivam Vatshayan - Medium
April 14, 2022 - ImportError: No module named ‘MySQL’ Error Usually occur even after sometimes using : pip install sql Traceback (most recent call last): File " ", line 1, in import …
🌐
GUVI Geeks Network
forum.guvi.in › posts › 4280 › import-mysql.connector-module-not-found-error
import Mysql.connector - Module Not Found Error - GUVI Geeks Network
From the internet resources, I came to know that I've to do some setting changes like "Setting-python interpreter- '+' icon- mysql-connector - install packages- ok". Even after doing this , I'm getting the same "ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package".
🌐
Delft Stack
delftstack.com › home › howto › python › importerror no module named mysql.connector
How to Fix ImportError: No Module Named mysql.connector | Delft Stack
March 11, 2025 - The most straightforward way to resolve the ImportError is to install the mysql-connector-python package. This package provides the necessary tools to connect to a MySQL database using Python.
🌐
Anaconda Forum
forum.anaconda.com › technical topics › pyscript
(Pyscript) website showing No module named 'mysql' - PyScript - Anaconda Forum
January 9, 2023 - I’m uploading the following .html to WinSCP, but facing ModuleNotFoundError: No module named 'mysql' html script title import mysql.connector mydb = mysql.connector.connect( host="196.168.100....
🌐
GitHub
github.com › Miserlou › Zappa › issues › 1401
ModuleNotFoundError: No module named 'mysql' · Issue #1401 · Miserlou/Zappa
February 18, 2018 - Context I'm trying to use MySQL Connector/Python with Zappa but keep getting ModuleNotFoundError: No module named 'mysql' after deploying. Everything works fine locally, the error only occurs on Lambda. I'm installing mysql-connector-pyt...
Author   Miserlou
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360007008180-mysql-connector-python-works-in-python-console-inside-Pycharm-but-not-in-IDE
mysql-connector-python works in python console inside Pycharm but not in IDE – IDEs Support (IntelliJ Platform) | JetBrains
File "C:\Users\ven\Desktop\Projects\test\mysql.py", line 3, in <module> mysql.connector.connect() AttributeError: module 'mysql' has no attribute 'connector' After bunch of Googling and researching... I ran this: from distutils.sysconfig import get_python_lib print(get_python_lib()) and get this: C:\Users\ven\Desktop\Projects\test\venv\Lib\site-packages I also checked the Project Interpreter settings and mysql-connector-python is showing up.