close

[Solved] Import: No module named mysql.connector using Python2

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Import: No module named mysql.connector using Python2 in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Import: No module named mysql.connector using Python2 Error Occurs?

Today I get the following error Import: No module named mysql.connector using Python2 in python.

How To Solve Import: No module named mysql.connector using Python2 Error ?

  1. How To Solve Import: No module named mysql.connector using Python2 Error ?

    To Solve Import: No module named mysql.connector using Python2 Error I was facing the similar issue. My env details – Python 2.7.11 pip 9.0.1 CentOS release 5.11 (Final)

  2. Import: No module named mysql.connector using Python2

    To Solve Import: No module named mysql.connector using Python2 Error I was facing the similar issue. My env details – Python 2.7.11 pip 9.0.1 CentOS release 5.11 (Final)

Solution 1

Depending on your python version and how you installed it, it is possible that mysql connector isn’t installed, you can install it with pip

To install mysql connector:

pip install mysql-connector-python

Solution 2


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
>>>

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read