entrez python api urllib2.URLError

时间:2016-02-01 06:20:25

标签: python api

我想在Python中使用Entrez API从Pubmed中获取一些信息,这只是官方教程的一个例子。

Entrez.email = "example@xx.com"     # Always tell NCBI who you are
handle = Entrez.einfo()
record = handle.read()
print record

这只是一个简单的例子。但有时我会遇到这个错误,并且不知道如何处理它。

 Traceback (most recent call last):
  File "/Users/Rabbit/PycharmProjects/test_2.7/Biopython.py", line 25, in <module>
    handle = Entrez.einfo()
  File "/Library/Python/2.7/site-packages/biopython-1.66-py2.7-macosx-10.10-intel.egg/Bio/Entrez/__init__.py", line 258, in einfo
    return _open(cgi, variables)
  File "/Library/Python/2.7/site-packages/biopython-1.66-py2.7-macosx-10.10-intel.egg/Bio/Entrez/__init__.py", line 516, in _open
    handle = _urlopen(cgi)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open
    response = self._open(req, data)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open
    '_open', req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1227, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1197, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 65] No route to host>

任何人都可以告诉我发生了什么。提前谢谢!

1 个答案:

答案 0 :(得分:0)

urllib2.URLError: <urlopen error [Errno 65] No route to host>

我从未使用过Entrez,但上述错误表明urllib2无法连接到主机。因此,请检查您是否有有效的互联网连接,或者您是否处于离线状态。