[英]How do I check how many versions of Python I have installed on my device using the cmd prompt?
I have Anaconda and Spyder, which I know use Python 3.6.5 and 3.6.6, alongside Python 3.7.0.我有 Anaconda 和 Spyder,我知道它们使用 Python 3.6.5 和 3.6.6,以及 Python 3.7.0。 How do I check how many version of python I have installed using the Windows Command Prompt?
如何使用 Windows 命令提示符检查我安装了多少版本的 python?
The python launcher ( "C:\\WINDOWS\\py.exe"
) has a list command: py.exe -0
It displays all installed python versions. python 启动器 (
"C:\\WINDOWS\\py.exe"
) 有一个列表命令: py.exe -0
它显示所有已安装的 python 版本。 If all you want is a visual list, that works alone.如果您想要的只是一个可视化列表,那么它就可以单独工作。 In a batch script, however, you might want to count the versions:
但是,在批处理脚本中,您可能想要计算版本数:
setlocal enableDelayedExpansion
set pyvcount=0
for /f %%G in ('%SYSTEMROOT%\py.exe -0') do set /a pyvcount+=1
Unfortunately, the I cannot figure out how to stop the command from printing Installed Pythons found by py Launcher for Windows
to the console.不幸的是,我无法弄清楚如何阻止命令将
Installed Pythons found by py Launcher for Windows
打印到控制台。
EDIT:编辑:
Hide the output by redirecting error stream to nul通过将错误流重定向到 nul 来隐藏输出
for /f %%G in ('%SYSTEMROOT%\py.exe -0 2>nul') do set /a pyvcount+=1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.