Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLError: <urlopen error [Errno 110] Connection timed out> #186

Open
zhoufengfan opened this issue Dec 21, 2021 · 0 comments
Open

URLError: <urlopen error [Errno 110] Connection timed out> #186

zhoufengfan opened this issue Dec 21, 2021 · 0 comments

Comments

@zhoufengfan
Copy link

When I run examples/lfw_evaluate.ipynb in the 12th code block, there occur this error:

---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)
/lib/python3.8/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1353             try:
-> 1354                 h.request(req.get_method(), req.selector, req.data, headers,
   1355                           encode_chunked=req.has_header('Transfer-encoding'))

/lib/python3.8/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1255         """Send a complete request to the server."""
-> 1256         self._send_request(method, url, body, headers, encode_chunked)
   1257 

/lib/python3.8/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1301             body = _encode(body, 'body')
-> 1302         self.endheaders(body, encode_chunked=encode_chunked)
   1303 

/lib/python3.8/http/client.py in endheaders(self, message_body, encode_chunked)
   1250             raise CannotSendHeader()
-> 1251         self._send_output(message_body, encode_chunked=encode_chunked)
   1252 

/lib/python3.8/http/client.py in _send_output(self, message_body, encode_chunked)
   1010         del self._buffer[:]
-> 1011         self.send(msg)
   1012 

/lib/python3.8/http/client.py in send(self, data)
    950             if self.auto_open:
--> 951                 self.connect()
    952             else:

/lib/python3.8/http/client.py in connect(self)
   1417 
-> 1418             super().connect()
   1419 

/lib/python3.8/http/client.py in connect(self)
    921         """Connect to the host and port specified in __init__."""
--> 922         self.sock = self._create_connection(
    923             (self.host,self.port), self.timeout, self.source_address)

/lib/python3.8/socket.py in create_connection(address, timeout, source_address)
    807         try:
--> 808             raise err
    809         finally:

/lib/python3.8/socket.py in create_connection(address, timeout, source_address)
    795                 sock.bind(source_address)
--> 796             sock.connect(sa)
    797             # Break explicitly a reference cycle

TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

URLError                                  Traceback (most recent call last)
/tmp/ipykernel_96110/651026656.py in <module>
      1 # Load pretrained resnet model
----> 2 resnet = InceptionResnetV1(
      3     classify=False,
      4     pretrained='vggface2'
      5 ).to(device)

/lib/python3.8/site-packages/facenet_pytorch/models/inception_resnet_v1.py in __init__(self, pretrained, classify, num_classes, dropout_prob, device)
    260         if pretrained is not None:
    261             self.logits = nn.Linear(512, tmp_classes)
--> 262             load_weights(self, pretrained)
    263 
    264         if self.classify and self.num_classes is not None:

/lib/python3.8/site-packages/facenet_pytorch/models/inception_resnet_v1.py in load_weights(mdl, name)
    325     cached_file = os.path.join(model_dir, os.path.basename(path))
    326     if not os.path.exists(cached_file):
--> 327         download_url_to_file(path, cached_file)
    328 
    329     state_dict = torch.load(cached_file)

/lib/python3.8/site-packages/facenet_pytorch/models/utils/download.py in download_url_to_file(url, dst, hash_prefix, progress)
     60     # certificates in older Python
     61     req = Request(url, headers={"User-Agent": "torch.hub"})
---> 62     u = urlopen(req)
     63     meta = u.info()
     64     if hasattr(meta, 'getheaders'):

/lib/python3.8/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    220     else:
    221         opener = _opener
--> 222     return opener.open(url, data, timeout)
    223 
    224 def install_opener(opener):

/lib/python3.8/urllib/request.py in open(self, fullurl, data, timeout)
    523 
    524         sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 525         response = self._open(req, data)
    526 
    527         # post-process response

/lib/python3.8/urllib/request.py in _open(self, req, data)
    540 
    541         protocol = req.type
--> 542         result = self._call_chain(self.handle_open, protocol, protocol +
    543                                   '_open', req)
    544         if result:

/lib/python3.8/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    500         for handler in handlers:
    501             func = getattr(handler, meth_name)
--> 502             result = func(*args)
    503             if result is not None:
    504                 return result

/lib/python3.8/urllib/request.py in https_open(self, req)
   1395 
   1396         def https_open(self, req):
-> 1397             return self.do_open(http.client.HTTPSConnection, req,
   1398                 context=self._context, check_hostname=self._check_hostname)
   1399 

/lib/python3.8/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
   1355                           encode_chunked=req.has_header('Transfer-encoding'))
   1356             except OSError as err: # timeout error
-> 1357                 raise URLError(err)
   1358             r = h.getresponse()
   1359         except:

URLError: <urlopen error [Errno 110] Connection timed out>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant