0
我一直在尋找/嘗試一切,我可以找到堆棧溢出,但沒有喜悅。我是Python的新手,所以我現在爲我的無知道歉,但是非常渴望/興奮地學習。macOS Sierra/Python2.7.13 URLError:<urlopen錯誤EOF發生違反協議(_ssl.c:661)>
macOS Sierra v10.12.5 (early 2011)
Python v2.7.13
urllib==1.21.1
urllib2==1498656401.94
urllib3==1.21.1
Homebrew installed
這裏是我收到的錯誤:
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>>
Traceback (most recent call last):
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",
l ine 154, in urlopen
return opener.open(url, data, timeout)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",
line 429, in open
response = self._open(req, data)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",
line 447, in _open
'_open', req)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",
line 407, in _call_chain
result = func(*args)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",
line 1241, in https_open
context=self._context)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py",
line 1198, in do_open
raise URLError(err)
URLError: <urlopen error EOF occurred in violation of protocol (_ssl.c:661)>
>>>
也許你正在使用非常舊版本的OpenSSL(0.9.8來到預裝和MacOS,這是很長很長過時)和服務器需要TLS 1.2或密碼不被舊的OpenSSL版本支持(如ECDHE密碼)。如果您提供您嘗試訪問的服務器的URL以及Python中使用的OpenSSL版本,即輸出:'python -c'import ssl;打印ssl.OPENSSL_VERSION''。 –
不大可能,哈哈:OpenSSL 0.9.8zh 2016年1月14日。冉「brew install openssl」....它說警告:openssl 1.0.21已經安裝。但是運行上面提供的代碼仍然會給我提供「OpenSSL 0.9.8zh 2016年1月14日」的輸出。 – KaiArtax
可以並行安裝多個OpenSSL安裝 - 但對於Python而言,它是相關的,它在編譯Python期間被鏈接。參見[在python 2.7中更新openssl](https://stackoverflow.com/questions/18752409/updating-openssl-in-python-2-7)。 –