简体   繁体   English

如何使用 cmd 提示符检查我的设备上安装了多少个 Python 版本?

[英]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.

相关问题 我安装了 2 个版本的 python,但 cmake 使用的是旧版本。 如何强制 cmake 使用较新版本? - I have 2 versions of python installed, but cmake is using older version. How do I force cmake to use the newer version? 如何检查 Python 模块的版本? - How do I check the versions of Python modules? 如何检查 Windows 上所有已安装的 Python 版本? - How can I check all the installed Python versions on Windows? 如何使用 python 脚本检查 Python 是否已安装? - How do I check if Python is installed using a python script? 如何检测我的 Python 代码是否在 PowerShell 或命令提示符 (cmd) 中运行 - How do I detect if my python code is running in PowerShell or the Command Prompt (cmd) 如何在 Amazon EMR 上安装多个版本的 numpy 以及如何删除早期版本? - How do I have multiple versions of numpy installed on Amazon EMR and how to I delete the early versions? 如何更新我的 python 环境,我的 python 设置是一团糟,我以许多不同的方式安装它 - How to do I update my python environment, my python setup is a mess and I installed it in many different ways 如何使用 Python 检查应用程序是否安装在 windows - How do I check if an application is installed in windows using Python 我的Python代码上有多少个线程? - How many threads do I have on my Python code? 运行 os.system 命令后,如何将输入传递给 cmd 提示符? - How do I pass inputs to cmd prompt after I have run the os.system command?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM