如何检查Windows上所有已安装的Python版本?

发布于 2021-01-29 15:18:43

请注意,我 不是在 问“如何检查我安装了哪个版本的Python”。

我已经在Windows计算机上安装了多个版本的Python,例如Python 2.7-64,Python 2.7-32和Python 3.7-32。

Python 3包含“ py”和“ pyw”,可帮助我轻松启动不同的Python,例如:

  • “ py -2.7”启动Python 2.7-64
  • “ py -2.7-32”启动Python 2.7-32
  • “ py -3.7-32”启动Python 3.7-32

我想知道的是,如何检查我在Windows PC上安装了多少个不同版本的Python,它们是什么版本?

PyCharm可以找到它,但是,一方面,我不知道它是否完整,而另一方面,我想知道Python是否提供了任何工具,或者操作系统是否可以做到这一点。

关注者
0
被浏览
150
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    我才得到答案。通过输入“ py -h”或“ py –help”,我得到了帮助消息:

    C:\Users\admin>py -h
    Python Launcher for Windows Version 3.7.1150.1013
    
    usage:
    py [launcher-args] [python-args] script [script-args]
    
    Launcher arguments:
    
    -2     : Launch the latest Python 2.x version
    -3     : Launch the latest Python 3.x version
    -X.Y   : Launch the specified Python version
         The above all default to 64 bit if a matching 64 bit python is present.
    -X.Y-32: Launch the specified 32bit Python version
    -X-32  : Launch the latest 32bit Python X version
    -X.Y-64: Launch the specified 64bit Python version
    -X-64  : Launch the latest 64bit Python X version
    -0  --list       : List the available pythons
    -0p --list-paths : List with paths
    

    告诉我“ -0”(零,而不是字母“ O”)列出了可用的python:

    C:\Users\admin>py -0
    Installed Pythons found by py Launcher for Windows
     -3.7-64 *
     -3.7-32
     -2.7-64
     -2.7-32
    

    而“ -0p”不仅列出版本,而且列出路径:

    C:\Users\admin>py -0p
    Installed Pythons found by py Launcher for Windows
     -3.7-64        C:\Users\admin\AppData\Local\Programs\Python\Python37\python.exe *
     -3.7-32        C:\Users\admin\AppData\Local\Programs\Python\Python37-32\python.exe
     -2.7-64        C:\Python27_64\python.exe
     -2.7-32        C:\Python27_32\python.exe
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看