Skip to content

Instantly share code, notes, and snippets.

@RahulDas-dev
Last active January 13, 2024 07:55
Show Gist options
  • Save RahulDas-dev/e9dcd42b2fe12f468ae91f9b5781c20f to your computer and use it in GitHub Desktop.
Save RahulDas-dev/e9dcd42b2fe12f468ae91f9b5781c20f to your computer and use it in GitHub Desktop.
Manage Multiple Python in Windows [ With out Conda ]

Managing Multiple Python Versions in Windows Terminal

This is a useful approach for switching between Python versions easily. I've organized the steps for better clarity:

Step 1: Remove Python Paths from PATH Variable.

Remove all existing Python installation paths from the system path and your accounts path variable.

Step 2: Create Bat Files for Each Python Version.

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%

Step 3: Add New Profile to Windows Terminal for Each Python Version.

  • Open Windows Terminal.
  • Go to "Settings" (Ctrl + ,) and add a new profile for each Python version.
  • image
  • image
  • click on + New Empty Profile
  • set following details
  • image

Step 4: Configure Command Line for Each Profile

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.

Step 5: Add Tab Title .

Add python_{version} in Tab title.

Step 6: Optional - Add Python Icon

  • 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.

Step 7: Launch Terminal with the Desired Python Version

  • Open Windows Terminal.
  • Choose the profile corresponding to the Python version you want to use.
  • image

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment