0

I have been searching/trying everything I could find on Stack Overflow, but no joy. I am new to Python, so I apologize now for my ignorance, but very eager/excited to learn.

macOS Sierra v10.12.5 (early 2011)
Python v2.7.13
urllib==1.21.1
urllib2==1498656401.94
urllib3==1.21.1
Homebrew installed

Here is the error I am receiving:

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)>
>>>
KaiArtax
  • 29
  • 4
  • 2
    Probably you are using a very old version of OpenSSL (0.9.8 came pre-installed with MacOS, which is long long obsolete) and the server requires TLS 1.2 or ciphers not supported by the old OpenSSL version (like ECDHE ciphers). More can only be said if you provide the URL of the server you are trying to reach and the version of OpenSSL as used in python, i.e. output of: `python -c 'import ssl; print ssl.OPENSSL_VERSION'`. – Steffen Ullrich Jul 13 '17 at 19:38
  • Not probably, haha: OpenSSL 0.9.8zh 14 Jan 2016. Ran "brew install openssl"....it said Warning: openssl 1.0.21 is already installed. But running the line you provided above still gives me the output of "OpenSSL 0.9.8zh 14 Jan 2016." – KaiArtax Jul 14 '17 at 13:21
  • 1
    It is possible to have multiple OpenSSL installations installed in parallel - but for Python it is relevant which is linked in during compilation of Python. See [Updating openssl in python 2.7](https://stackoverflow.com/questions/18752409/updating-openssl-in-python-2-7). – Steffen Ullrich Jul 14 '17 at 14:13
  • https://medium.com/@katopz/how-to-upgrade-openssl-8d005554401 Everything seemed to be moving until this part of the process (of course it was the very end): 3. And maybe you’ll need this too $ mkdir -p /usr/local/lib $ ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/ $ ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/ Close Terminal and reopen then check version $ openssl version -a It is still wanting to return OpenSSL 0.9.8zh – KaiArtax Jul 14 '17 at 14:58
  • Problems while trying to build your own Python with a current OpenSSL are not covered by the topic of your original question but should be asked instead as a new question. Nobody will expect to find such mostly unrelated questions and answers in the comments later and thus valuable information will be lost. – Steffen Ullrich Jul 14 '17 at 15:38

1 Answers1

0

I had a two fold problem. The steps provided above by @Steffen_Ullrich solved the first half of the issue. Here is the second half, thank you @zwer!

Python and 'print ssl.OPENSSL_VERSION' prints wrong version

KaiArtax
  • 29
  • 4