This is a useful approach for switching between Python versions easily. I've organized the steps for better clarity:
Remove all existing Python installation paths from the system path
and your accounts path
variable.
Create a bat file (e.g., python_39.bat) for each Python version.
@set PYTHONPATH=C:\Users\usrer123\AppData\Local\Programs\Python\Python39
@set PATH=%PYTHONPATH%;%PYTHONPATH%\Scripts;%PATH%
- Open Windows Terminal.
- Go to "Settings" (Ctrl + ,) and add a new profile for each Python version.
- click on
+ New Empty Profile
- set following details
In the newly created profiles, configure the command line as follows:
%SystemRoot%\System32\cmd.exe /k "{directory}\python_{version}.bat"
Replace {directory} with the path where your bat files are located.
Add python_{version} in Tab title.
- Optionally, you can add a Python icon (py.ico) for a more visual identification.
- icons are available in
DLLs
directory of your installed Python folder.
Now, you can easily switch between Python versions by selecting the appropriate profile in the Windows Terminal.
This setup allows you to keep different Python environments isolated and simplifies the management of multiple Python installations on your system. Customize it further according to your needs, and feel free to reach out if you have any questions!