我正在尝试在 GitPod 中使用 Python imaplib 库。
根据文档,我导入了 imaplib 并使用以下代码行实例化了 IMAP4 对象:
M = imaplib.IMAP4()
这将返回以下消息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/imaplib.py", line 198, in __init__
self.open(host, port)
File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/imaplib.py", line 303, in open
self.sock = self._create_socket()
File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/imaplib.py", line 293, in _create_socket
return socket.create_connection((host, self.port))
File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/socket.py", line 808, in create_connection
raise err
File "/home/gitpod/.pyenv/versions/3.8.12/lib/python3.8/socket.py", line 796, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
问题是 imaplib 无法连接到自己的套接字,所以我应该先以某种方式激活 GitPod 中的那个套接字?