3
votes

import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package

pip install mysql-connector-python-rf python version-3.7.2

pip install mysql-connector-python-rf

pip install mysql-connector-python succesfully installed import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package whereas when I import mysql gives no error message

1
Uninstall all the installed mysql-connector-python or similar packages. Just install pip install mysql-connector. If you have multiple versions of python install you will have to install using python -m pip install mysql-connector.CodeIt
What is the file name? You must not name your script mysql.py Python tries to import mysql from the script and it fail.drew

1 Answers

4
votes

resolved by renaming the file to anything else than MySQL.py as it just tries to load itself I guess