pip list
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
argparse (1.4.0)
Beaker (1.3.1)
cas (0.15)
cups (1.0)
cupshelpers (1.0)
decorator (3.0.1)
distribute (0.6.10)
---and other modules
你需要在bash中运行
pip list
,而不是在python中。pip list
是一个shell命令。你应该在你的shell(bash/cmd)中运行它,而不是从python解释器中调用它。如果你想从python脚本中运行,你需要先导入
pip
模块:然而,如果你只想检查
pip
是否存在于本地,并且你运行的是Linux,我建议你使用bash'的which
命令:它应该显示在bash'的
PATH
/aliases中是否能找到该命令,如果能找到,它实际执行的是什么。如果你真的需要从Python脚本中执行,你可以把导入语句放在
try...except
块中:在CMD中,键入:
它将显示所有已安装模块的列表,包括版本号。
输出: