Skip to content

Instantly share code, notes, and snippets.

@VojislavM
Last active December 13, 2019 09:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VojislavM/7020658e0dbf66c149f48c962e39d559 to your computer and use it in GitHub Desktop.
Save VojislavM/7020658e0dbf66c149f48c962e39d559 to your computer and use it in GitHub Desktop.
When using two version of the python (2 and 3) on windows 10 and you need to make one of the versions "main" version. By main version I mean when you call "python" in cmd your main version will open. To run this script you need some kind of "linux on windows" system, like MinGW. To add both pythons to your windows PC you can follow this tutorial h…
#!/bin/bash
#change the dots with your python 2 and 3 paths and leave .exe file names as they are, you can find them in windows env variables
#python2 path
py2=../python.exe
py2_n=../python2.exe
#python3 path
py3=../python.exe
py3_n=../python3.exe
VERSION=$1
echo python master change the python version for python.exe
#echo $VERSION
#if no parameter ask for it
if [ -z $VERSION ]
then
echo which version you want to be main 2 or 3
read VERSION
echo you chose version $VERSION
else
echo you chose version $VERSION
fi
if [[ $VERSION -ne '2' ]] && [[ $VERSION -ne '3' ]]
then
echo wrong verson
exit 1
fi
#find current main version
if [ -f "$py2" ]
then
echo "python 2 is main"
elif [ -f "$py3" ]
then
echo "python 3 is main"
else
echo there is a problem with versions
exit 1
fi
#change verson
#version 2 main
if [[ $VERSION -eq '2' ]] && [[ -f "$py3" ]]
then
mv $py3 $py3_n
mv $py2_n $py2
elif [[ $VERSION -eq '3' ]] && [[ -f "$py2" ]]
then
mv $py2 $py2_n
mv $py3_n $py3
else
echo version $VERSION is already main
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment