Skip to content

Instantly share code, notes, and snippets.

@jrnewell
Created July 20, 2014 22:01
Show Gist options
  • Save jrnewell/311542cc274b7b5fbee3 to your computer and use it in GitHub Desktop.
Save jrnewell/311542cc274b7b5fbee3 to your computer and use it in GitHub Desktop.
Switch between Python2 and Python3 on MS Windows cmd
@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