requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘localhost‘, port=8123): Max retries ex

参考requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘localhost‘, port=8123): Max retries ex_visdom max retries_两只蜡笔的小新的博客-CSDN博客

一、前言:

在一次运行代码的到时候,突然爆出一长串的错误:

  File "/home/wyc/software/anconda3/envs/pytroch_test/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8123): Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd7efc3b400>: Failed to establish a new connection: [Errno 111] Connection refused'))
[Errno 111] Connection refused

这个是因为visdom.server未启动的原因。

解决方法:

python -m visdom.server

注意:python多环境的情况下,需要在相应的代码运行的环境下面启动。

二、可能出现的问题:

第一次启动需要下载配置文件,由于来自github上面,所以可能不能下载成功,报错内容如下:/home/wyc/software/anconda3/envs/pytroch_test/lib/python3.9/site-packages/visdom/server.py:39: DeprecationWarning: zmq.eventloop.ioloop is deprecated in pyzmq 17. pyzmq now works with default tornado and asyncio eventloops.
  ioloop.install()  # Needs to happen before any tornado imports!
Checking for scripts.
Downloading scripts, this may take a little while
ERROR:root:Error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129) while downloading https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_SVG

解决办法:

1. 使用梯子科学上网,GitHub - kuweicai/document-sharing 下载该链接下的文件,

将下载好的文件里面的 static,覆盖代码环境下面的文件

博主的路径如下:

/home/wyc/software/anconda3/envs/pytroch_test/lib/python3.9/site-packages/visdom/static

2. 修改server.py文件,第117行,将该行注释掉就行了:

/home/wyc/software/anconda3/envs/pytroch_test/lib/python3.9/site-packages/visdom/server.py

三、成功解决:

再次运行,启动服务的代码:python -m visdom.server,出现西面的返回信息就代表,成功了

requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8097) 是一个网络连接错误的异常。它表示在与特定的主机和端口建立连接时出现问题。具体错误信息是"Max retries exceeded with url: /env/main (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000019B93886588>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it',))"。这个错误通常是因为无法连接到目标主机所导致的。可能的原因包括目标主机处于离线状态,网络连接不稳定,或目标主机主动拒绝了连接请求。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [requests.exceptions.ConnectionError:HTTPSConnectionPool(host](https://blog.csdn.net/a6864657/article/details/94381948)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [visdom安装及启动/requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘localhost‘, port=...](https://blog.csdn.net/qq_42514371/article/details/127838311)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值