0

I have installed MySQL connector for python 3.6 in centos 7 If I search for installed modules with below command

it's showing as below pip3.6 freeze mysql-connector==2.1.6 mysql-connector-python==2.1.7 pymongo==3.6.1

pip3.6 search mysql-connector mysql-connector-python (8.0.6) -MYSQL driver written in Python INSTALLED: 2.1.7 LATEST: 8.0.6 mysql-connector (2.1.6) - MySQL driver written in Python INSTALLED: 2.1.6 (latest)

MySQL connector installed.But when trying to run the program using MySQL connector then its showing error no module installed MySQL connector.I am using MariaDB 10.0

python3.6 mysql1.py Traceback (most recent call last): File "mysql1.py", line 2, in import mysql.connector as mariadb File "/root/Python_environment/my_Scripts/mysql.py", line 2, in import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package

can any one know how to resolve

2 Answers 2

1

You must not name your script mysql.py — in that case Python tries to import mysql from the script — and fails.

Rename your script /root/Python_environment/my_Scripts/mysql.py to something else.

Sign up to request clarification or add additional context in comments.

Comments

0

This is the problem I faced in Environment created by python.Outside the python environment i am able to run the script.Its running succefully.In python environment i am not able run script i am working on it.if any body know can give suggestion on this

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.