简体   繁体   中英

"Please upgrade python" when I have 3.7 and "Please upgrade pip" when I have 20.0.2. Why am I getting this error?

I wanted to download the PIL library to crop images on python, but I just can't download the module. Here's what appears on the terminal

$ pip install PIL

    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 shows up

$ python3 -m pip install PIL
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 shows up

$ pip install --upgrade pip
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
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
Python 2.7.10
$ python3 --version
Python 3.7.1

So I downloaded pip3 and then tried the command

$ pip3 install PIL
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
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3: No module named pip3

Here are some details about my pip and python

$ which pip3
/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3
$ which python3
/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, Pip2(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 dont need to take any action to upgrade pip3.

If you want to use PIL in python then i recommend you install pillow . Pillow is the PIL of python 3. You should be able to install pillow with pip3 install Pillow . Pillow supercedes 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 wont call pip2 by mistake.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM