Python MySQL (import pymysql)

122 views Asked by At

If I use IDLE editor there is no any error occurs. but when I use sublime or VS code and for output I run my file (python test.py) in terminal or CMD it generate this error I try many commands to resolve but nothing changes like

pip install mysql

pip install pymysql

pip install mysql-connector

and watch many error videos but this error is not resolving. If someone know please help regard this.

On IDLE SHELL everything's works fine but in CMD these errors come. I also attached Screenshots for further information.

enter image description here

enter image description here

Error in CMD:

Traceback (most recent call last):
  File "C:\Users\Ubaid\Desktop\Python\test.py", line 1, in <module>
    import pymysql
  File "C:\Users\Ubaid\AppData\Roaming\Python\Python312\site-packages\pymysql\__init__.py", line 59, in <module>
    from . import connections  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ubaid\AppData\Roaming\Python\Python312\site-packages\pymysql\connections.py", line 7, in <module>
    import socket
  File "C:\Program Files\Python312\Lib\socket.py", line 55, in <module>
    import os, sys, io, selectors
  File "C:\Program Files\Python312\Lib\selectors.py", line 12, in <module>
    import select
  File "C:\Users\Ubaid\Desktop\Python\select.py", line 2, in <module>
    mysql=pymysql.connect(
          ^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'pymysql' has no attribute 'connect' (most likely due to a circular import)

Command Prompt Screen shot

IDLE ScreenShot

0

There are 0 answers