Unable to Access a URL Using Tensorflow_hub

I am new to tensorflow and I am trying to run a research project. It seems like tensorflow_hub cannot access the url “TensorFlow Hub

The research project is running on python 2.7 and tensorflow 1.8 environment. To run tensorflow_hub on this environment, I downloaded tensorfloe_hub == 0.4.0 version.

This line of code get the error

self.lm_hub = hub.Module(config[“lm_path”].encode(“utf-8”), trainable=False)

This is the error message.

Using tensorflow hub: TensorFlow Hub
Traceback (most recent call last):
File “decoder.py”, line 37, in
data = LSGNData(config)
File “/home/xuan/Desktop/linux_research/lsgn-master/lsgn_data.py”, line 51, in init
self.lm_hub = hub.Module(config[“lm_path”].encode(“utf-8”), trainable=False)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/site-packages/tensorflow_hub/module.py”, line 147, in init
self._spec = as_module_spec(spec)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/site-packages/tensorflow_hub/module.py”, line 36, in as_module_spec
return load_module_spec(spec)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/site-packages/tensorflow_hub/module.py”, line 60, in load_module_spec
path = registry.resolver(path)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/site-packages/tensorflow_hub/registry.py”, line 42, in call
return impl(*args, **kwargs)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/site-packages/tensorflow_hub/compressed_module_resolver.py”, line 103, in call
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/site-packages/tensorflow_hub/resolver.py”, line 400, in atomic_download
download_fn(handle, tmp_dir)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/site-packages/tensorflow_hub/compressed_module_resolver.py”, line 98, in download
response = url_opener.open(request)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/urllib2.py”, line 429, in open
response = self._open(req, data)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/urllib2.py”, line 447, in _open
‘_open’, req)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/urllib2.py”, line 407, in _call_chain
result = func(*args)
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/urllib2.py”, line 1241, in https_open
File “/home/xuan/anaconda3/envs/py27/lib/python2.7/urllib2.py”, line 1198, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [Errno 110] Connection timed out>

Could anyone explain what is going on and how to fix this problem, please? Thank you very much.


I think for the old TF (1.x) you should use TFHub version 0.11.0 (guide).

One other thing I’d suggest is to move to a newer Python and TF version. you might get many issues that were already solved in newer versions.