问题
I was working with Steffen Ullrich on a previous issue, and now it is morphing into a new issue. So taking his advice (thank you Steffen), I am posting a separate question:
$ python -c 'import ssl; print ssl.OPENSSL_VERSION'
OpenSSL 0.9.8zh 14 Jan 2016
I have attempted just about everything under the sun (so it feels) to fix it.
$ brew install openssl
Warning: openssl 1.0.21 is already installed
So I have both, but it only reads/links to OpenSSL 0.9.8zh?
I am new to Python/Homebrew on my Mac.
回答1:
You also need to install Python that is linked to that Homebrew OpenSSL library, try with:
brew install python --with-brewed-openssl
Beware, tho, that it will not replace your 'native' Python, you'll have to relink it. By default, it will be installed in /usr/local/Cellar/python/<version>
, whereas the version
may change with time. If you want you can relink the python binary as:
sudo mv /usr/bin/python /usr/bin/python.old 2>/dev/null
sudo ln -s -f /usr/local/Cellar/python/<version>/bin/python /usr/bin/python
But I'd suggest you to create a local link so you can use both python versions:
sudo mv /usr/local/bin/python /usr/local/bin/python.old 2>/dev/null
sudo ln -s -f /usr/local/Cellar/python/<version>/bin/python /usr/local/bin/python
(of course, replacing the <version>
with whichever version of Python Homebrew installed at the time of trying the above)
And then when you need this 'upgraded' Python just launch your scripts with /usr/local/bin/python script.py
or use /usr/local/bin/python
as their shebang.
回答2:
Incase anyone else has the same issues, I wanted to provide the link to the original (1st half of the issue) so that others may get a full picture.
macOS Sierra/Python2.7.13 URLError: <urlopen error EOF occurred in violation of protocol (_ssl.c:661)>
来源:https://stackoverflow.com/questions/45109794/python-and-print-ssl-openssl-version-prints-wrong-version