首页 > 解决方案 > Python 3 无法在 CMD 中导入套接字,但在 IDLE 中可用

问题描述

我已经在我的电脑上安装了 python 3.7。似乎无法import在 CMD 中进行套接字:

C:\Users\Sina\py
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python37-32\lib\socket.py", line 49, in <module>
import _socket
ImportError: Module use of python27.dll conflicts with this version of 
Python.
>>>

但令人惊讶的是,我能够socket在 IDLE (Python 3.7) 中导入。

我在python 3.7的安装目录(C:\Python37-32)中搜索但没有找到任何'python27.dll'文件

编辑: “C:\Users\Sina”中有一个 _socket.pyd 文件,该文件用于产生冲突。我删除了它,问题得到了解决。感谢阿兰菲!

标签: pythoncmd

解决方案


推荐阅读