Python Forum
How to find out from outside Python (in Windows) the current version of Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to find out from outside Python (in Windows) the current version of Python?
#1
Assume I installed in the past Python on my Windows 10 system.

Is there a way to find out from OUTSIDE Python the currently installed version of Python?

This should be done with a one-line command from command line e.g. in CommandPrompt or in Powershell.

Thank you
Reply
#2
in cmd prompt python --version or python3 --version
pstein likes this post
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
Also py.exe will find(or run) all version installed.
py has been there sine the early Python 3 releases.
Use py --list or for help py --help
# Only py will use last version installed 
G:\div_code
λ py --version
Python 3.12.0

# Run code
G:\div_code
λ py hello.py
C:\Python312\python.exe
hello world

# Use Python 3.9
G:\div_code
λ py -3.9 hello.py
C:\Python39\python.exe
hello world

# Install to eg only 3.9 
G:\div_code
λ py -3.9 -m pip install requests
Requirement already satisfied: requests in c:\python39\lib\site-packages (2.26.0)

# Use Python 2.7
G:\div_code
λ py -2.7 hello.py
C:\Python27\python.exe
hello world
Reply
#4
py.exe

is NOT part of the Windows Python v3.12.0 installation.
So your suggestion is useless for me
Reply
#5
(Oct-04-2023, 03:44 AM)pstein Wrote: py.exe

is NOT part of the Windows Python v3.12.0 installation.
So your suggestion is useless for me
It dos install,but not in Python folder.
Before it did install to C:\Windows,now it install to C:\Users\<Pc User>\AppData\Local\Programs\Python\Launcher\py.exe
The reason for this is OS environment path,so it always available.
[Image: PY3xI5.png]

C:\code
λ py --version
Python 3.12.0

C:\code
λ py -3.10 --version
Python 3.10.4

C:\code
λ where py
C:\Users\Tom\AppData\Local\Programs\Python\Launcher\py.exe
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to add Python folder in Windows Registry ? Touktouk 1 280 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Python Launcher (on Windows) only necessary when 2 or more Python versions installed? pstein 1 333 Feb-17-2024, 12:43 PM
Last Post: deanhystad
  Triggering a ps1 script in remote windows server via http python request jasveerjassi 1 383 Jan-26-2024, 07:02 PM
Last Post: deanhystad
  run part of a script with a different version of Python jdog 2 463 Jan-09-2024, 08:49 PM
Last Post: jdog
  Can't Find Python (or Something) pklind 2 550 Nov-26-2023, 11:11 AM
Last Post: snippsat
Question Need Help with Vehicle Routing Problem with Time Windows (VRPTW) in Python kasper321421312 1 577 Nov-10-2023, 08:19 PM
Last Post: snippsat
  Installation of packages to newest Python version from previous one Andrzej_Andrzej 3 849 Jul-15-2023, 11:32 AM
Last Post: snippsat
  pip installs in a different python version and directory than the default 3.11 ao_tex_mal 9 3,460 Jun-20-2023, 02:55 PM
Last Post: snippsat
  Python script running under windows over nssm.exe JaroslavZ 0 725 May-12-2023, 09:22 AM
Last Post: JaroslavZ
  [split] How to resolve version conflicts in Python? atonalwilson 1 1,005 May-04-2023, 09:02 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020