【发布时间】:2016-07-07 15:33:36
【问题描述】:
我正在练习 google-python 课程。但是,我遇到了 urllib 的问题。这是简化的代码:
import urllib
url = 'http://www.google.com'
ufile=urllib.urlopen(url)
这段代码确实有效,但如果我将 url 更改为其他一些,例如:
url = 'https://developers.google.com/edu/python/utilities#exceptions'
会报错:
IOError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
完整的错误信息如下:
Traceback (most recent call last):
File "practice2.py", line 4, in <module>
ufile=urllib.urlopen(url)
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/urllib.py", line 213, in open
return getattr(self, name)(url)
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/urllib.py", line 443, in open_https
h.endheaders(data)
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/httplib.py", line 1049, in endheaders
self._send_output(message_body)
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/httplib.py", line 893, in _send_output
self.send(msg)
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/httplib.py", line 855, in send
self.connect()
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/httplib.py", line 1274, in connect
server_hostname=server_hostname)
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/ssl.py", line 352, in wrap_socket
_context=self)
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/ssl.py", line 579, in __init__
self.do_handshake()
File "/home/jren/Canopy/appdata/canopy-1.6.2.3262.rh5-x86_64/lib/python2.7/ssl.py", line 808, in do_handshake
self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
非常感谢您阅读本文!
【问题讨论】:
-
检查您的计算机时钟显示的时间是否正确!