Created
February 11, 2017 23:14
-
-
Save OmarWKH/ad2947a46390b8aacf9fe69ba652168a to your computer and use it in GitHub Desktop.
Change py's python version for current cmd instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: changes python versoin invoked by 'py' for current cmd instance | |
:: https://docs.python.org/using/windows.html#customizing-default-python-versions | |
:: my set up: | |
:: installed python 3 and added it to environment variables | |
:: installed python 2 to another folder without adding it | |
:: added this script to my environment variables | |
:: now I use python 3 by default, and when I need to use 2 I type 'pyv' (you can change the name) | |
:: usage: | |
:: if an argument was given, version = argument | |
:: example: 'pyv 2.6' => 'py' will run python 2.6 if installed | |
:: else, toggle between python 2/default python | |
:: example: 'pyv' => 'py will run python 2, 'pyv' again will undo that | |
@echo off | |
if not "%~1"=="" ( | |
set PY_PYTHON=%1 | |
echo py is version %1 for this instance | |
) else ( | |
if not "%PY_PYTHON%"=="2" ( | |
set PY_PYTHON=2 | |
echo py is version 2 for this instance | |
) else ( | |
set PY_PYTHON="" | |
echo py is the default version for this instance | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment