9

Trying to store values in sql using Python Cgi script, I have downloaded the Connector/Python for MySQL successfully. I used the following code in Python's shell to test my connection:

import mysql.connector

I received the following error message:

ModuleNotFoundError: No module named 'mysql'

when trying to import MySQL.connector.

3
  • 2
    What exact mysql package did you install. What is the name of it? Did you check the documentation for the package you installed to know what you are supposed to use to import it?
    – idjaw
    Commented Feb 19, 2017 at 1:16
  • Please be more specific. I don't understand what you are referring to by "the community instr".
    – idjaw
    Commented Feb 19, 2017 at 1:54
  • Not enough details. Commented Feb 19, 2017 at 3:19

3 Answers 3

10

Just try this command:

pip install mysql-connector-python-rf

then try your command again, it'll run correctly.

2
8

try below command

pip install mysql-connector

1
2

I had the same problem that was created by conflicting package names.

Try creating a fresh virtual environment, then running pip install mysql-connector-python.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.