0
votes

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

2 Answers

1
votes

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.

0
votes

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