所以我在三个地方安装了 python:一台 Windows 机器、一台 Pi(运行 Kali)和我的 Mac。我的 Mac 是唯一一台在导入套接字库或依赖于套接字库的库(即 ipwhois)时出现此错误的设备。我在 sudo 中运行它,我尝试了 python 2 和 3 但仍然没有成功。这是我得到的:
Python 2.7.14 (default, Oct 1 2017, 15:09:23)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "socket.py", line 15, in <module>
serverSocket = socket(AF_INET, SOCK_STREAM)
NameError: name 'AF_INET' is not defined
>>> import ipwhois
Traceback (most recent call last):
File …Run Code Online (Sandbox Code Playgroud)