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. According to some stack exchange post its something to do with the newer (Python 3.0 and later) versions i believe.
🌐
Latenode
community.latenode.com › other questions › mysql
Cannot resolve mysql.connector module import error - MySQL - Latenode Official Community
July 25, 2025 - Hey everyone, I’m facing a really annoying problem with my Python code. It keeps giving me an import error for the mysql.connector module. I went ahead and installed the package using pip install mysql-connector-python, and the installation went smoothly. Yet, when I try to execute my script, ...
🌐
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 ...
🌐
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 Overflow
stackoverflow.com › questions › 71259511 › import-mysql-connector-could-not-be-resolved-pylance
python - import mysql.connector could not be resolved pylance - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", password="yourpassword" ) cursor = mydb.cursor() print(mydb)
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › python-no-module-named-mysql
ModuleNotFoundError: No module named 'mysql' in Python | bobbyhadz
April 4, 2024 - To solve the error, install the module by running the pip install mysql-connector-python command. Open your terminal in your project's root directory and install the mysql-connector-python module.
🌐
Reddit
reddit.com › r/learnpython › vscode - mysql connector not found
r/learnpython on Reddit: VSCODE - mysql connector not found
April 22, 2021 -

I am starting with Python and did short script in VScode. When I try to run it I get this error:

PS C:\Users\spider> & C:/Python39/python.exe c:/Users/spider/drek.py
Traceback (most recent call last):
File "c:\Users\spider\drek.py", line 5, in <module>
import mysql.connector
ModuleNotFoundError: No module named 'mysql'

I ran pip install mysql-connector and it installed it. If I run pip list I get this:

PS C:\Users\spider> pip list

Package Version
---------------------- -------
mysql-connector 2.2.9
mysql-connector-python 8.0.24
pip 21.0.1
protobuf 3.15.8
six 1.15.0
wheel 0.36.2

PS C:\Users\spider>

Why I can't use MySql commands and how to fix it?

🌐
HatchJS
hatchjs.com › home › import mysql.connector could not be resolved (pylance: report missing imports)
Import mysql.connector could not be resolved (PyLance: report missing imports)
December 25, 2023 - Import mysql.connector could not ... imports. * This common error can be fixed by updating your pip installation or by adding the mysql connector library to your Python path....
🌐
Sada Tech
tech.sadaalomma.com › sql › import-mysql-connector-could-not-be-resolved
import mySQL connector could not be resolved - SADA Tech
February 15, 2024 - If the mySQL connector JAR file is not included in the build path or is not referenced correctly, your application will be unable to resolve it. Now that we have identified the possible causes of the error, let’s move on to the troubleshooting process. We will explore various solutions and workarounds to help you resolve the “Import mySQL Connector Could Not Be Resolved” error effectively.
🌐
PythonAnywhere
pythonanywhere.com › forums › topic › 33650
WSGI error: No module named mysql.connector : Forums : PythonAnywhere
In the error logs it says "No module named mysql.connector". This is what I have not been able to resolve. It runs from CLI but not from the browser. ckselu | 4 posts | Oct. 13, 2023, 1:27 a.m. | permalink · @ckselu -- we have a help page for debugging the import error.
🌐
sebhastian
sebhastian.com › no-module-named-mysql
Python ModuleNotFoundError: No module named 'mysql' | sebhastian
February 28, 2023 - To fix this error, you need to install MySQL Connector using pip. If you already have the module installed, make sure you are using the correct version of Python, deactivate the virtual environment if you have one, and check for the Python version ...
🌐
Reddit
reddit.com › r/learnpython › unable to import mysql.connector despite installation.
r/learnpython on Reddit: Unable to import mysql.connector despite installation.
October 20, 2016 -

I'm running Ubuntu 12.04 and using pycharm IDE with the anaconda interpreter.

I have installed the mysql.connector module, however whenever I try to import and run the mysql.connector, I get the 'ImportError: No module named mysql.connector'.

If I run import mysql.connector within the python console I receive... Traceback (most recent call last): File "/home/my_name/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2885, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-2-8eb88b59635b>", line 1, in <module> import mysql.connector File "/usr/lib/pycharm-community/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) ImportError: No module named mysql.connector

The file path to the mysql connector I can find is /usr/lib/pymodules/python2.7/mysql/connector

Anyone have an idea what is going wrong here?

Thanks in advance to any replies or solutions...

🌐
Stack Overflow
stackoverflow.com › questions › 70375630 › import-error-i-cant-import-mysql-connector-in-python
Import Error. I can't import mysql-connector in Python - Stack Overflow
import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 63 'Import "Path.to.own.script" could not be resolved Pylance (reportMissingImports)' in VS Code using Python 3.x on Ubuntu 20.04 LTS
🌐
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 - This usually occurs for one of two reasons: the module is not installed in your Python environment, or you are using a different Python interpreter than the one where the module is installed.
🌐
Pipedream
pipedream.com › bugs
Python: Can't use mysql.connector, getting No module named '_version' - Bugs - Pipedream
May 27, 2022 - I just added a step and just by writing import mysql.connector from pipedream.script_helpers import (steps, export) import mysql.connector # Reference data from previous steps print(steps["trigger"]["context"]["id"]) …