【Python】Visdom:ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
问题描述
Traceback (most recent call last):
File "<PATH>\lib\site-packages\urllib3\connection.py", line 196, in _new_conn
sock = connection.create_connection(
File "<PATH>\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
raise err
File "<PATH>\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<PATH>\lib\site-packages\urllib3\connectionpool.py", line 789, in urlopen
response = self._make_request(
File "<PATH>\lib\site-packages\urllib3\connectionpool.py", line 495, in _make_request
conn.request(
File "<PATH>\lib\site-packages\urllib3\connection.py", line 398, in request
self.endheaders()
File "<PATH>\lib\http\client.py", line 1278, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "<PATH>\lib\http\client.py", line 1038, in _send_output
self.send(msg)
File "<PATH>\lib\http\client.py", line 976, in send
self.connect()
File "<PATH>\lib\site-packages\urllib3\connection.py", line 236, in connect
self.sock = self._new_conn()
File "<PATH>\lib\site-packages\urllib3\connection.py", line 211, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000002022D66A140>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<PATH>\lib\site-packages\requests\adapters.py", line 667, in send
resp = conn.urlopen(
File "<PATH>\lib\site-packages\urllib3\connectionpool.py", line 843, in urlopen
retries = retries.increment(
File "<PATH>\lib\site-packages\urllib3\util\retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/caffe2torch_tripletloss (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002022D66A140>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<PATH>\lib\site-packages\visdom\__init__.py", line 756, in _send
return self._handle_post(
File "<PATH>\lib\site-packages\visdom\__init__.py", line 720, in _handle_post
r = self.session.post(url, data=data)
File "<PATH>\lib\site-packages\requests\sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
File "<PATH>\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "<PATH>\lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "<PATH>\lib\site-packages\requests\adapters.py", line 700, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /env/caffe2torch_tripletloss (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000002022D66A140>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))
Without the incoming socket you cannot receive events from the server or register event handlers to your Visdom client.
原因分析
应用程序尝试连接到运行在localhost
上端口8097
的Visdom服务器,但连接被拒绝。因为Visdom服务器没有运行。
Visdom 是 Facebook AI Research (FAIR) 开发的一个可视化工具,用于实时可视化数据。它特别适用于机器学习实验,允许用户创建、组织和共享数据和模型的可视化。
解决方案
在运行训练脚本之前启动Visdom服务器:
python -m visdom.server
标签:Visdom,WinError,10061,lib,py,site,File,line,packages
From: https://blog.csdn.net/qq_34988204/article/details/144632723