Created
July 20, 2014 22:01
-
-
Save jrnewell/311542cc274b7b5fbee3 to your computer and use it in GitHub Desktop.
Switch between Python2 and Python3 on MS Windows cmd
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
@echo off | |
goto START | |
------------------------------------------------------- | |
py-ver.bat | |
set the PYTHON_HOME to version 2 or 3 | |
Created Sat May 11 13:00:00 2014 | |
------------------------------------------------------- | |
:START | |
SETLOCAL ENABLEDELAYEDEXPANSION | |
if /i "%1"=="2" ( | |
echo Using python version %PYTHON2_HOME% | |
set newPyPath=%PYTHON2_HOME% | |
set oldPyPath=%PYTHON3_HOME% | |
) else ( | |
echo Using python version %PYTHON3_HOME% | |
set newPyPath=%PYTHON3_HOME% | |
set oldPyPath=%PYTHON2_HOME% | |
) | |
echo Replacing !oldPyPath! to !newPyPath! in PATH | |
call set newPath=%%PATH:!oldPyPath!=!newPyPath!%% | |
ENDLOCAL & set PATH=%newPath% | |
:FINISHED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment