当我有3.7时为“请升级python”,而当我有20.0.2时为“请升级pip”。为什么会出现此错误?

时间:2020-03-01 01:44:59

标签: python pip upgrade

我想下载PIL库以在python上裁剪图像,但是我无法下载该模块。这是终端上显示的内容

$ 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

然后我尝试了这个。但是出现另一个错误

$ 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.

所以我试图升级我的点子。但这会出现

$ 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)

当我检查我的点子版本时,它会显示

$ pip --version
pip 20.0.2 from /Library/Python/2.7/site-packages/pip-20.0.2-py2.7.egg/pip (python 2.7)

当我检查我的python版本时,显示此内容

$ python --version
Python 2.7.10
$ python3 --version
Python 3.7.1

所以我下载了pip3,然后尝试了命令

$ 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

我也尝试了他们所说的话。

$ python3 -m pip3 install PIL
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3: No module named pip3

以下是有关我的pip和python的一些细节

$ which pip3
/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3
$ which python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3

我该如何彻底解决这个问题?

1 个答案:

答案 0 :(得分:1)

由于不再支持python 2, Pip2(由pippython -m pip调用)抱怨您应该使用python3。python 3的程序包管理器称为pip3(由pip3python3 -m pip调用)

您的pip3当前是最新版本,您无需采取任何措施即可升级pip3。

如果您想在python中使用PIL,那么我建议您install pillow。枕头是python 3的PIL。 您应该可以使用pip3 install Pillow安装枕头。枕头取代PIL。 (除非您特别想在python 2中使用PIL)

也许您想将终端配置为将pip别名为pip3,这样您就不会错误地调用pip2。