簡體   English   中英

當我有 3.7 時“請升級 python”,當我有 20.0.2 時“請升級 pip”。 為什么我收到這個錯誤?

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

我想下載 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(由pippython -m pip調用)抱怨你應該使用 python 3。python 3 的包管理器稱為 pip3(由pip3python3 -m pip調用)。

您的 pip3 目前是最新版本,您無需采取任何措施來升級 pip3。

如果你想在 python 中使用 PIL 那么我建議你安裝 Pillow Pillow 是 python 3 的 PIL。你應該可以用pip3 install Pillow 枕頭取代了 PIL。 (除非你特別想在 python 2 中使用 PIL)

也許您想將終端配置為將 pip 別名為 pip3,這樣您就不會錯誤地調用 pip2。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM