windows或Ubuntu中请求github.com请求超时,或在下载GitHub文件出现:<urlopen error [Errno 110] Connection timed out>
欢迎大家关注笔者,你的关注是我持续更博的最大动力原创文章,转载告知,盗版必究windows或Ubuntu中请求github.com请求超时,或在下载GitHub文件出现:urlopen error [Errno 110] Connection timed out 文章目录:1 windows中请求github.com超时1.1 windows中ping github.com超时1.2 解决wind
windows或Ubuntu中请求github.com请求超时,或在下载GitHub文件出现:urlopen error [Errno 110] Connection timed out
文章目录:
1 windows中请求github.com超时
1.1 windows中ping github.com超时
C:\Users\zfxx_1>ping github.com
正在 Ping github.com [13.229.188.59] 具有 32 字节的数据:
请求超时。
请求超时。
请求超时。
请求超时。
13.229.188.59 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 0,丢失 = 4 (100% 丢失),
但是当你正常ping baidu.com是没有问题的
C:\Users\zfxx_1>ping baidu.com
正在 Ping baidu.com [39.156.69.79] 具有 32 字节的数据:
来自 39.156.69.79 的回复: 字节=32 时间=28ms TTL=48
来自 39.156.69.79 的回复: 字节=32 时间=26ms TTL=48
来自 39.156.69.79 的回复: 字节=32 时间=26ms TTL=48
来自 39.156.69.79 的回复: 字节=32 时间=26ms TTL=48
39.156.69.79 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 26ms,最长 = 28ms,平均 = 26ms
C:\Users\zfxx_1>
ping 不通,主要原因可能是本地DNS不能够正确解析域名导致的
1.2 解决windows中ping github.com超时问题
1、打开:C:\Windows\System32\drivers\etc\hosts
配置文件,然后在其末尾添加如下内容
192.30.255.112 github.com git
185.31.16.184 github.global.ssl.fastly.net
注意:
如果不能够保存,需要权限,此时可以把修改后的hosts文件另存,然后再复制替换C:\Windows\System32\drivers\etc\hosts
即可!
2、修改完之后,然后再重新打开一个终端,再ping github.com,即通!
C:\Users\zfxx_1>ping github.com
正在 Ping github.com [192.30.255.112] 具有 32 字节的数据:
来自 192.30.255.112 的回复: 字节=32 时间=352ms TTL=47
来自 192.30.255.112 的回复: 字节=32 时间=353ms TTL=47
来自 192.30.255.112 的回复: 字节=32 时间=353ms TTL=47
来自 192.30.255.112 的回复: 字节=32 时间=355ms TTL=47
192.30.255.112 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 352ms,最长 = 355ms,平均 = 353ms
C:\Users\zfxx_1>
2 Ubuntu中请求github.com超时
修改和windows中类似
1、需要再root权限下修改 /etc/hosts
配置文件,然后再其中添加如下两行内容:
192.30.255.112 github.com git
185.31.16.184 github.global.ssl.fastly.net
2、修改完之后,然后重新打开一个终端,再ping github.com 即通!
p(base) shl@zfcv:~$ ping github.com
PING github.com (192.30.255.112) 56(84) bytes of data.
64 bytes from github.com (192.30.255.112): icmp_seq=1 ttl=47 time=386 ms
64 bytes from github.com (192.30.255.112): icmp_seq=2 ttl=47 time=372 ms
64 bytes from github.com (192.30.255.112): icmp_seq=4 ttl=47 time=371 ms
64 bytes from github.com (192.30.255.112): icmp_seq=6 ttl=47 time=376 ms
64 bytes from github.com (192.30.255.112): icmp_seq=7 ttl=47 time=371 ms
64 bytes from github.com (192.30.255.112): icmp_seq=8 ttl=47 time=372 ms
64 bytes from github.com (192.30.255.112): icmp_seq=9 ttl=47 time=371 ms
64 bytes from github.com (192.30.255.112): icmp_seq=11 ttl=47 time=371 ms
64 bytes from github.com (192.30.255.112): icmp_seq=12 ttl=47 time=371 ms
64 bytes from github.com (192.30.255.112): icmp_seq=13 ttl=47 time=371 ms
64 bytes from github.com (192.30.255.112): icmp_seq=14 ttl=47 time=371 ms
64 bytes from github.com (192.30.255.112): icmp_seq=15 ttl=47 time=372 ms
64 bytes from github.com (192.30.255.112): icmp_seq=16 ttl=47 time=372 ms
64 bytes from github.com (192.30.255.112): icmp_seq=18 ttl=47 time=376 ms
3 我遇到这个问题的场景
我在Ubuntu18.04环境中,想要运行yolov5的,然后在下载文件的时候一直超时
>>> import torch
>>> model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True)
运行上面的代码,会从github下载一些文件,然后就会出现超时:urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>
(yolov5-v3) shl@zfcv:~/project/yolov5_hub$ python
Python 3.8.5 (default, Aug 5 2020, 08:36:46)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=False)
Downloading: "https://github.com/ultralytics/yolov5/archive/master.zip" to /home/shl/.cache/torch/hub/master.zip
vi Traceback (most recent call last):
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/urllib/request.py", line 1350, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/http/client.py", line 1010, in _send_output
self.send(msg)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/http/client.py", line 950, in send
self.connect()
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/http/client.py", line 1417, in connect
super().connect()
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/http/client.py", line 921, in connect
self.sock = self._create_connection(
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/socket.py", line 808, in create_connection
raise err
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/socket.py", line 796, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/site-packages/torch/hub.py", line 345, in load
repo_dir = _get_cache_or_reload(github, force_reload, verbose)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/site-packages/torch/hub.py", line 144, in _get_cache_or_reload
download_url_to_file(url, cached_file, progress=False)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/site-packages/torch/hub.py", line 379, in download_url_to_file
u = urlopen(req)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/urllib/request.py", line 1393, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/home/shl/anaconda3/envs/yolov5-v3/lib/python3.8/urllib/request.py", line 1353, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 110] Connection timed out>
后面通过上面的方法解决了问题!!!
♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠
更多推荐
所有评论(0)