环境
win10、pycharm、python3.7、pytorch1.7、Anaconda3、已安装visdom
报错
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接
定位错误原因
visdom启动失败,需要激活visdom服务器
解决方法
- 打开Anaconda Prompt(Anaconda3)
- 激活pytorch,输入conda activate pytorch
- 输入python -m visdom.server,但是报错ModuleNotFoundError: No module named ‘jsonpatch’
(pytorch) C:\Users\hp>python -m visdom.server
Traceback (most recent call last):
File "D:\Anaconda3\envs\pytorch\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\Anaconda3\envs\pytorch\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Anaconda3\envs\pytorch\lib\site-packages\visdom\server.py", line 20, in <module>
import jsonpatch
ModuleNotFoundError: No module named 'jsonpatch'
- 在这里下载jsonpatch-0.8.tar.gz(我的环境下这个版本适用),把它放到你的目录下,例如我放到C:\Users\hp这个路径下,然后输入pip install jsonpatch-0.8.tar.gz
(pytorch) C:\Users\hp>pip install jsonpatch-0.8.tar.gz
Processing c:\users\hp\jsonpatch-0.8.tar.gz
Building wheels for collected packages: jsonpatch
Building wheel for jsonpatch (setup.py) ... done
Created wheel for jsonpatch: filename=jsonpatch-0.8-py3-none-any.whl size=5392 sha256=4b88ecb74799213f7bb19564817dc513142566f4099435a7546d2526569408e3
Stored in directory: c:\users\hp\appdata\local\pip\cache\wheels\62\17\19\2eddcd622ec6d4b4d1d89a2f3f23588748ce930cdbbfc52974
Successfully built jsonpatch
Installing collected packages: jsonpatch
Successfully installed jsonpatch-0.8
- 输入python -m visdom.server,但是报错ModuleNotFoundError: No module named ‘jsonpointer’
(pytorch) C:\Users\hp>python -m visdom.server
Traceback (most recent call last):
File "D:\Anaconda3\envs\pytorch\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\Anaconda3\envs\pytorch\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Anaconda3\envs\pytorch\lib\site-packages\visdom\server.py", line 20, in <module>
import jsonpatch
File "D:\Anaconda3\envs\pytorch\lib\site-packages\jsonpatch.py", line 51, in <module>
import jsonpointer
ModuleNotFoundError: No module named 'jsonpointer'
- 于是在这里下载jsonpointer-0.7.tar.gz,把它放到你的目录下,例如我放到C:\Users\hp这个路径下,然后输入pip install jsonpointer-0.7.tar.gz
(pytorch) C:\Users\hp>pip install jsonpointer-0.7.tar.gz
Processing c:\users\hp\jsonpointer-0.7.tar.gz
Building wheels for collected packages: jsonpointer
Building wheel for jsonpointer (setup.py) ... done
Created wheel for jsonpointer: filename=jsonpointer-0.7-py3-none-any.whl size=3830 sha256=063c9c658d87fa460f436f91605c8923ef0a9bd29ec600be292abaa15180b51f
Stored in directory: c:\users\hp\appdata\local\pip\cache\wheels\78\73\c8\2a7e28e453ba25e9e5768235269b23dd87447440b1b1ff6ef0
Successfully built jsonpointer
Installing collected packages: jsonpointer
Successfully installed jsonpointer-0.7
- 再次输入python -m visdom.server,成功
(pytorch) C:\Users\hp>python -m visdom.server
D:\Anaconda3\envs\pytorch\lib\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!
It's Alive!
INFO:root:Application Started
You can navigate to http:
注意
在上述我的环境中,运行使用visdom的程序时,要在Anaconda Prompt中,先激活pytorch,再激活visdom服务器,并且保持窗口,不能关闭窗口,否则还会报错ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接 具体命令是
- conda activate pytorch
- python -m visdom.server
参考博客
博客1 博客2
|