Python Forum

Full Version: MySql connection problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am trying to connect MySql using python, but it's showing error.


Error:
Traceback (most recent call last): File "/home/ai/Documents/Database/mysql.py", line 1, in <module> import mysql.connector File "/home/ai/Documents/Database/mysql.py", line 1, in <module> import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package
I try to install pip3 mysql.connector also but after installing it's now working and showing same error.
I would guess that's because Python is trying to import mysql, which is your file name, so I think it's trying to import itself. If you change the name of your file, you should be fine. Be careful of overriding your imports with local file names :)