Python MySQL(导入pymysql)

问题描述 投票:0回答:1

如果我使用IDLE编辑器,则不会发生任何错误。但是当我使用 sublime 或 VS code 并作为输出时,我在终端或 CMD 中运行我的文件(python test.py),它会生成此错误,我尝试了很多命令来解决,但没有任何改变,例如

pip安装mysql

pip 安装 pymysql

pip install mysql-connector 并观看了许多错误视频,但此错误并未解决。如果有人知道请帮忙解决这个问题。

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

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)

enter image description here

命令提示符屏幕截图

enter image description here

空闲屏幕截图

python python-3.x pymysql
1个回答
0
投票

我在终端上输出的任何文件都会给出相同的错误,但在idle3上运行时没有错误

© www.soinside.com 2019 - 2024. All rights reserved.