How to solve the pip and ssl version problem when install Pillow on MacOS
This article shows how to solve the pip and ssl version problem when install Pillow:
1. The environment
- Python 2.7.10
- OS: Mac OS 10.12.4
2. The problem
➜ bswen: pip install pillow
Collecting pillow
Could not fetch URL https://pypi.python.org/simple/pillow/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Could not find a version that satisfies the requirement pillow (from versions: )
No matching distribution found for pillow
3. The reason
After google, I found the reason is:
The ssl support is deprecated in the pip(version 9.*),you should upgrade to pip 10
3. Solve the problem
So I installed pyenv like this:
➜ bswen: brew install pyenv
And Then add this script to ~/.zshrc
eval "$(pyenv init -)"
And then quit the terminal and install the new python version:3.6.5
➜ bswen: pyenv install 3.6.5
And then set the local version to 3.6.5
➜ bswen: pyenv local 3.6.5
Verify the version:
➜ bswen: python --version
Python 3.6.5
Upgrade to pip 10:
➜ bswen: pip install --upgrade pip
At last, we install the Pillow like this:
➜ bswen: pip install Pillow
Verify the pillow installation:
➜ bswen: python
Python 3.6.5 (default, Apr 22 2018, 14:43:19)
[GCC 4.2.1 Compatible Apple LLVM 8.0 (clang-800)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>>
The pillow is installed successfully.
You can find detail documents about the python pip here: