I wanted to download the PIL library to crop images on Python, but I just can't download the module. Here's what appears in the terminal:
pip install PIL
Output:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
Then I tried this out. But another error showed up:
python3 -m pip install PIL
Output:
Could not find a version that satisfies the requirement PIL (from versions: )
No matching distribution found for PIL
You are using pip version 10.0.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
So I tried to upgrade my pip. But then this showed up:
pip install --upgrade pip
Output:
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pip in /Library/Python/2.7/site-packages/pip-20.0.2-py2.7.egg (20.0.2)
When I check my pip version it shows this:
pip --version
Output:
pip 20.0.2 from /Library/Python/2.7/site-packages/pip-20.0.2-py2.7.egg/pip (python 2.7)
When I check my Python version it shows this
python --version
Output:
Python 2.7.10
python3 --version
Output:
Python 3.7.1
So I downloaded pip3 and then tried the command
pip3 install PIL
Output:
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL
I also tried what they said.
python3 -m pip3 install PIL
Output:
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3: No module named pip3
Here are some details about my pip and the Python interpreter:
which pip3
Output:
/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3
which python3
Output:
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
How do I solve this once and for all?
Because Python 2 is no longer supported, Pip 2 (invoked by either pip
or python -m pip
) is complaining that you should use Python 3. The package manager for Python 3 is called pip3 (invoked by pip3
or python3 -m pip
).
Your pip3 is currently the latest version and you don’t need to take any action to upgrade pip3.
If you want to use PIL in Python then I recommend you to install Pillow. Pillow is the PIL of Python 3.
You should be able to install Pillow with pip3 install Pillow
. Pillow supersedes PIL. (unless you specifically want to use PIL with Python 2)
Perhaps you want to configure your terminal to alias pip to pip3, so you won’t call pip2 by mistake.