我升级并安装了最新的 Python 版本 3.8.1。
问题是,当我输入
python --version
在终端上,当我输入时,我得到 Python 2.7.16
python3 --version
我得到 Python 3.8.1。但如果我尝试
pip install -U selenium
我收到一条消息:
"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"
我不明白为什么它在 Python 2.7 上运行
最佳答案
千万不要调用 pip
, pip3
, 或 pipX.Y
脚本 除非你真的明白其中的含义是什么。
相反,总是更喜欢调用您所针对的确切 Python 解释器并告诉它运行 pip 的 可执行模块 :
path/to/my/pythonX.Y -m pip
path/to/my/python -m pip
path/to/venv/bin/python -m pip
pythonX.Y -m pip
python3 -m pip
python -m pip
我推荐阅读Brett Cannon's article "Why you should use
python -m pip
" .
关于Python --version 不更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60348649/