This is if you have both the versions installed.

Go to This PCRight-clickClick on PropertiesAdvanced System Settings.

You will see the System Properties. From here navigate to the Advanced Tab -> Click on Environment Variables.

You will see a top half for the user variables and the bottom half for System variables.

Check the System Variables and double-click on the Path (to edit the Path).

Check for the path of Python(which you wish to run i.e. Python 2.x or 3.x) and move it to the top of the Path list.

Restart the Command Prompt, and now when you check the version of Python, it should correctly display the required version.

Answer from Aditya Deshpande on Stack Overflow
Top answer
1 of 16
191

This is if you have both the versions installed.

Go to This PCRight-clickClick on PropertiesAdvanced System Settings.

You will see the System Properties. From here navigate to the Advanced Tab -> Click on Environment Variables.

You will see a top half for the user variables and the bottom half for System variables.

Check the System Variables and double-click on the Path (to edit the Path).

Check for the path of Python(which you wish to run i.e. Python 2.x or 3.x) and move it to the top of the Path list.

Restart the Command Prompt, and now when you check the version of Python, it should correctly display the required version.

2 of 16
120

The Python installer installs Python Launcher for Windows. This program (py.exe) is associated with the Python file extensions and looks for a "shebang" comment to specify the python version to run. This allows many versions of Python to co-exist and allows Python scripts to explicitly specify which version to use, if desired. If it is not specified, the default is to use the latest Python version for the current architecture (x86 or x64). This default can be customized through a py.ini file or PY_PYTHON environment variable. See the docs for more details.

Newer versions of Python update the launcher. The latest version has a py -0 option to list the installed Pythons and indicate the current default. py -h lists complete Python Launcher options as well as Python options.

Here's how to check if the launcher is registered correctly from the console:

C:\>assoc .py
.py=Python.File

C:\>ftype Python.File
Python.File="C:\Windows\py.exe" "%1" %*

Above, .py files are associated with the Python.File type. The command line for Python.File is the Python Launcher, which is installed in the Windows directory since it is always in the PATH.

For the association to work, run scripts from the command line with script.py, not "python script.py", otherwise python will be run instead of py. If fact it's best to remove Python directories from the PATH, so "python" won't run anything and enforce using py.

py.exe can also be run with switches to force a Python version:

py -3 script.py       # select latest Python 3.X version to be used.
py -3.6 script.py     # select version 3.6 specifically.
py -3.9-32 script.py  # select version 3.9 32-bit specifically.
py -0                 # list installed Python versions (latest PyLauncher).

Additionally, add .py;.pyw;.pyc;.pyo to the PATHEXT environment variable and then the command line can just be script with no extension.

🌐
Reddit
reddit.com › r/learnpython › change actual python-version in cmd?
r/learnpython on Reddit: Change actual python-version in cmd?
May 21, 2024 -

Generally i was using the latest python version 3.12. in my terminalk
So when i created a virtual environment with

python -m venv xyz

the created virtual environment was under 3.12

For testing purposes it was now necessary to also install python version 3.9.

But now when i am using venv to create a new virtual environment it is the version 3.9.

How can i change the "standard" python-version bakc to 3.12. when i am creating a virtual environment using venv?

Discussions

How to switch between python version Windows - Stack Overflow
Im trying to switch between python versions 3.6.6 and 3.7.0 in windows. I tried py -3.6.6 and doesn't work. Looked for options in py -h, found none. I saw a couple of answers for switching between ... More on stackoverflow.com
🌐 stackoverflow.com
How to change default python in `py-launcher` at windows?
Hello, I tried to install multiple python versions on my windows machine, I have this version: ❯ py --list -V:3.11 * Python 3.11 (64-bit) -V:3.10 Python 3.10 (64-bit) -V:3.9 Python 3.9 (64-bit) How do I change the default python version to 3.10 when I type py in terminal? because if I type ... More on discuss.python.org
🌐 discuss.python.org
3
0
May 20, 2022
How to change python version in command prompt if I have 2 python version installed - Stack Overflow
I have installed Anaconda 2 & 3 in my system. Anaconda 2 contains python 2.7 & Anaconda 3 contains python 3.6. I need to run my python code using command prompt & I need to use python ... More on stackoverflow.com
🌐 stackoverflow.com
How to set multi Python version environment to easy switch
How to install different versions of Python and easy to switch it, Thanks! Windows for business | Windows Client for IT Pros | User experience | Other More on learn.microsoft.com
🌐 learn.microsoft.com
2
0
February 21, 2023
🌐
Python.org
discuss.python.org › python help
How to change default python in `py-launcher` at windows? - Python Help - Discussions on Python.org
May 20, 2022 - Hello, I tried to install multiple python versions on my windows machine, I have this version: ❯ py --list -V:3.11 * Python 3.11 (64-bit) -V:3.10 Python 3.10 (64-bit) -V:3.9 Python 3.9 (64-b…
🌐
CircleCI
support.circleci.com › hc › en-us › articles › 16708605403035-How-to-Change-your-Python-Version-within-the-Windows-Executor
How to Change your Python Version within the Windows Executor – CircleCI Support Center
February 2, 2026 - - run: name: installed version verification shell: bash command: | py -3.9 -m venv venv39 source ./venv39/Scripts/activate python --version
Find elsewhere
Top answer
1 of 7
32


As you can see, I have both Python2 and Python3 installed.


I hope you know that the path of the python executable has to be added to the PATH environment variable in Windows. As you can see, the path of Python2 is placed above the path of Python3 in my system.

How does the cmd run commands?
It searches for an executable with the same name in the directory the cmd has been opened in, then goes and searches for the command in the locations provided in the Windows PATH variable, from TOP to BOTTOM. Which means, it gets the path to Python2 before it can get to the path of Python3. Therefore, every time you type python in your cmd, it runs Python2.
Both Python2 and Python3 executables have the same name in Windows so it never runs python3.

What seems like an obvious solution?
You might think, changing the name of python.exe to python3.exe for the Python3 executable will solve your problem. You are partially right, it will work. But you have to use python3 file.py or python3 --version, which I think, is understandable. But, pip will no longer work if you change the name of the original python executable. You will no longer be able to install external packages and modules.

How can this problem be solved?
You can create an alias for the Python3 executable called python3.bat.
.exe and .bat files can be called from the cmd directly without using their extension. We always write python filename.py instead of python.exe filename.py although both are correct. The same can be done with .bat files.
Go back to the first image and notice the python3.bat file below python.exe. That is my way of calling python3 without renaming my original python executable.

python3.bat
Create a new file using notepad or something and paste this %~dp0python %*
I don't fully understand how this works except that dp0 basically runs python from inside the same directory and %* passes all the arguments to the python executable. Place this file inside your Python3 installation directory and your problem will hopefully be solved.


python3 basically runs your python3.bat file, which in turn runs the python.exe from its folder and passes the arguments to it.

I hope this solves your problem.

2 of 7
6

You should have python3 also in your path. You could use python3 to run your script:

python3 <your_script>

But to answer your question, you could use alias and update it as python.

$ python --version    
Python 2.7.6
$ alias python=python3
$ python --version    
Python 3.6.4
🌐
Medium
medium.com › @dandi.mahendris › set-up-different-python-version-in-windows-1d5cf3b652dd
Set-up Different Python version in Windows | by Dandi Mahendris | Medium
July 25, 2023 - Set-up Different Python version in Windows Running PowerShell as Administrator in windows. Check the default version by using python --version Open the python directory, usually default install …
🌐
GitHub
github.com › pyenv-win › pyenv-win
GitHub - pyenv-win/pyenv-win: pyenv for Windows. pyenv is a simple python version management tool. It lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well. · GitHub
pyenv for Windows. pyenv is a simple python version management tool. It lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.
Starred by 7.1K users
Forked by 573 users
Languages   VBScript 53.7% | Python 30.9% | Batchfile 11.6% | PowerShell 3.7% | Shell 0.1%
🌐
Python
docs.python.org › 3 › using › windows.html
4. Using Python on Windows — Python 3.14.3 documentation
This is a standalone tool that makes Python available as global commands on your Windows machine, integrates with the system, and supports updates over time. You can download the Python Install Manager from python.org/downloads or through the Microsoft Store app. Once you have installed the Python Install Manager, the global python command can be used from any terminal to launch your current latest version of Python.
🌐
C# Corner
c-sharpcorner.com › article › how-to-manage-multiple-versions-of-python-on-windows-11
How To Manage Multiple Versions Of Python On Windows 11
April 13, 2022 - You can download the installer for Python 3.10 here. You can learn to install python3 on Windows here. We will now create copies of the python executable and rename them to python27 and python310. This is necessary so that system knows the python version to run.
🌐
JetBrains
jetbrains.com › help › datalore › switch-python-versions.html
Switch Python versions | Datalore Documentation
December 8, 2025 - /opt/python/envs/$ENV_NAME/bin/python -m pip install ipykernel==5.5.3 ipython==7.31.1 ipython_genutils==0.2.0 jedi==0.17.2 aiohttp==3.8.3 # Any other library can be installed in the same way /opt/python/envs/$ENV_NAME/bin/python -m pip install pandas>=1.5.3 · Restart the machine to apply changes. Open the notebook where you want to customize your environment. Open the Attached data tool from the left-hand sidebar. Click Notebook files to expand the list and open environment.yml. Edit the environment.yml file as shown in the examples below: datalore-env-format-version: "0.2" datalore-package-manager: "conda" datalore-base-env: "py39" dependencies:
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1182826 › how-to-set-multi-python-version-environment-to-eas
How to set multi Python version environment to easy switch - Microsoft Q&A
February 21, 2023 - What this does under Windows, is to trawl the %PATH% environment variable, checking for an executable, either batch file (.bat), command file (.cmd) or some other executable to run (this is controlled by the PATHEXT environment variable), that matches the name given. When it finds the correct file to run the file is being run. Now, if you've installed two python versions 2.5 and 2.6, the path will have both of their directories in it, something like PATH=c:\python\2.5;c:\python\2.6 but Windows will stop examining the path when it finds a match.
🌐
H2S Media
how2shout.com › home › coding › set python 3 as your default “python version” on windows 10/11
Set Python 3 as your default "Python Version" on Windows 10/11
January 17, 2023 - Learn how to resolve multiple Python version issues by making Python 3 as the default one on Windows 10 or 7 via Environmental variables.
Top answer
1 of 3
1

Here's my discoveries.

Step 1. Go to System Properties. Click on Environment Variables

Step 2. Add new variables, such as PYTHON_27_HOME

  • PYTHON_27_HOME:%ProgramFiles%\Python27\
  • PYTHON_36_HOME:%ProgramFiles%\Python36\
  • PYTHON_HOME:%PYTHON_27_HOME%

In my case, PYTHON_27_HOME(Python 2.7) is pointing to C:\Program Files\Python27\. You can replace this with your own path to python. %PYTHON_HOME% has a default value pointing to %PYTHON_27_HOME%, which is the path for Python 2.7. That's my preference, feel free to adjust accordingly. Be aware that there're 32-bit and 64-bit python. Please use %PROGRAMFILES% for path to C:\Program Files and %PROGRAMFILES(X86)% for path to C:\Program Files (x86).

Step 3. Select PATH and click on Edit. PATH

Step 4. Click on New and add %PYTHON_HOME%. %PYTHON_HOME% will be added to PATH automatically every time you launch a command prompt.


In order to switch between different versions of python in cmd, here's the trick.

Step 5. I created a batch file with

@echo off
:: Switch Python version
DOSKEY python27=SET PATH=%PYTHON_27_HOME%;%PATH%
DOSKEY python36=SET PATH=%PYTHON_36_HOME%;%PATH%

Basically, it disables echo and creates two alias. In batch file any string after :: is the comments. Every time, python27 or python36 is called, it re-exports %PATH% with the new Python path. Save it as profile.bat. You can name it whatever you want.

Step 6. Search for regedit (Registry Editor). Click on Edit > New > String Value. Give AutoRun as the Value name and %USERPROFILE%\profile.bat as the Value data. Here, please put your actual path value to the profile.bat we just created. So, whenever a command prompt is opened, it automatically loads profile.bat, which creates those two alias in the script.

Step 7. Close any command prompt you're using or just open a new command prompt. This is because your changes will not affect opened cmd window. Environment changes only happens to new CMD.

Step 8. Verify your results here.

If you're using different Java versions, same trick applies, too. Find my javac environment setting here.

2 of 3
1

I think the easiest way to support various versions of Python, as well as other languages, is the asdf version manager. It allows you to set a version of Python globally, as well as in each project folder. This means that you can set your Python version to dynamically change based upon the folder you're working in.

asdf version manager

I haven't used Windows for almost 20 years, but I've heard that Windows 10 sports an Ubuntu-based subsystem for Linux. I don't know if asdf will work with that, but it is worth a try. Just use the instructions for setting asdf up with bash.

🌐
Brainly
brainly.com › computers and technology › high school › how do you set the default python version on windows?
[FREE] How do you set the default Python version on Windows? - brainly.com
November 27, 2023 - To set the default Python version on Windows, modify the 'Path' variable in environment variables to move your preferred Python version to the top. This ensures that when you type 'python' in Command Prompt, the system recognizes the correct version.
🌐
Reddit
reddit.com › r/learnpython › how to set default version when multiple versions are installed
r/learnpython on Reddit: How to set default version when multiple versions are installed
June 8, 2022 -

I have both 3.10 and 3.11b3 installed on my windows 10 machine. I'd like py.exe to launch 3.10.

I had read that I should create py.ini and pyw.ini in both \windows and C:\Users<user>\AppData\Local\Programs\Python\Launcher\ and the files should contain:

[defaults]
python=3.10

I've done this, but py.exe launches 3.11b3. I don't have any other py.ini files. How do I fix this so \windows\py.exe launches my preferred default version?

EDIT: see https://stackoverflow.com/questions/68121982/multiple-python-versions-installed-how-to-set-the-default-version-for-py-exe

I could use py -3.10 to launch, but from the link there should be a way to just use py