PS C:\Users\yashi\OneDrive\桌面\Python Projects> python -m pip list
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
Package Version
---------- -------
pip 20.0.1
selenium 3.141.0
setuptools 41.2.0
urllib3 1.25.7
python -m pip list
有效。但是,它显示了安装在python 2.7中的软件包。我正在使用python 3.8。
我尝试了python -3.8 -m pip list
,py3.8 -m pip list
,python3 -m pip list
,py3 -m pip list
但是它们都不起作用。
答案 0 :(得分:0)
使用pip
(或实际上直接使用任何其他Python脚本)时,确保使用哪个Python解释器很重要。通常在调用pip
时使用哪个Python解释器是很明显的,但也经常发生这样的情况,即不清楚。因此,如有疑问,最好显式调用Python解释器。通常:
> python -m pip list
> # instead of 'pip list'
> python3 -m pip list
> # instead of 'pip3 list'
如果仍然有疑问,甚至可以更进一步,并使用完整的Python解释器路径:
> C:\Path\To\Python38\python.exe -m pip list
在Windows下,有一个非常有用的工具Python Launcher for Windows,当安装了多个版本的Python解释器时,该工具可以在某种程度上简化工作:
> py -2.7 -m pip list
> py -3.8 -m pip list
关于该主题的有趣读物:Brett Cannon's article "Why you should use python -m pip
"