close

[Solved] ImportError: No module named ‘mysql’

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to import mysql.connector But I am facing following error ImportError: No module named ‘mysql’ 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 ImportError: No module named ‘mysql’ Error Occurs?

I am trying to import mysql.connector But I am facing following error.

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

How To Solve ImportError: No module named ‘mysql’ Error?

  1. How To Solve ImportError: No module named ‘mysql’ Error ?

    To Solve ImportError: No module named ‘mysql’ Error You just need to install mysql-connector with this command and then you can import mysql.connector. If You are using Python 3 then run this command: pip3 install mysql-connector. If you are using Python 2.X then use this command: pip install mysql-connector.
    Second solution is You just need to simply install from cli pip3 install mysql-connector-python-rf. And then import like this: import mysql.connector. Now your error must be solved.

  2. ImportError: No module named ‘mysql’

    To Solve ImportError: No module named ‘mysql’ Error You just need to install mysql-connector with this command and then you can import mysql.connector. If You are using Python 3 then run this command: pip3 install mysql-connector. If you are using Python 2.X then use this command: pip install mysql-connector.
    Second solution is You just need to simply install from cli pip3 install mysql-connector-python-rf. And then import like this: import mysql.connector. Now your error must be solved.

Solution 1: install mysql-connector

You just need to install mysql-connector with this command and then you can import mysql.connector.

If You are using Python 3 then run this command.

pip3 install mysql-connector

If you are using Python 2.X then use this command.

pip install mysql-connector

Solution 2: install mysql-connector-python-rf

You just need to simply install from cli.

pip3 install mysql-connector-python-rf

And then import like this.

import mysql.connector

Now your error must be solved.

Summary

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?

Also, Read

Leave a Comment