我想下载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。但随后就出现了这个
$ 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版本时,它显示如下
$ 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我如何一劳永逸地解决这个问题?
发布于 2020-03-01 10:02:45
因为Python2不再受支持,所以Pip2(由pip或python -m pip调用)抱怨您应该使用Python3。Python3的包管理器称为pip3(由pip3或python3 -m pip调用)。
您的pip3当前是最新版本,您无需执行任何操作即可升级pip3。
如果你想在python中使用PIL,那么我推荐你使用install pillow。Pillow是Python3的PIL,你应该可以用pip3 install Pillow安装pillow。枕头取代了PIL。(除非您特别想在python 2中使用PIL )
也许您希望将终端配置为将pip作为pip3的别名,这样您就不会错误地调用pip2。
https://stackoverflow.com/questions/60471280
复制相似问题