Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

FYI, I have already installed the Connector/Python for MySQL successfully. I used the below code in the shell to test my connection:

import mysql.connector

I received the following error message:

Traceback (most recent call last):

  File "<pyshell#8>", line 1, in <module>

    import mysql.connector

ImportError: No module named 'mysql'

Kindly help!

1 Answer

0 votes
by (107k points)

You have to use the 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

For verification:

$ 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

>>>

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Nov 22, 2020 in Python by ashely (50.2k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...