我想下载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
我如何一劳永逸地解决这个问题
因为python 2不再受支持, Pip2(由
pip
或python -m pip
调用)抱怨应该使用python 3。python 3的包管理器称为pip3(由pip3
或python3 -m pip
调用)您的pip3目前是最新版本,您无需采取任何措施升级pip3
如果您想在python中使用PIL,那么我建议您install pillow。枕头是python 3的PIL。 您应该能够使用
pip3 install Pillow
安装枕头。枕头取代了枕头。(除非您特别希望将PIL与python 2一起使用)也许您想将终端配置为别名pip到pip3,这样您就不会错误地调用pip2
相关问题 更多 >
编程相关推荐