Skip to content

Instantly share code, notes, and snippets.

@VojislavM
Created December 12, 2019 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VojislavM/e955b982bf7c49a6fdd3db301d1fd4f9 to your computer and use it in GitHub Desktop.
Save VojislavM/e955b982bf7c49a6fdd3db301d1fd4f9 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
#!/bin/bash
#python2 path
py2=v2/v.txt
#C:/Python27/python.exe
#python3 path
py3=v3/v.txt
#C:/Users/vojislav/AppData/Local/Programs/Python/Python38-32/python.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 v3/v.txt v3/v3.txt
mv v2/v2.txt v2/v.txt
elif [[ $VERSION -eq '3' ]] && [[ -f "$py2" ]]
then
mv v2/v.txt v2/v2.txt
mv v3/v3.txt v3/v.txt
else
echo version $VERSION is already main
fi
#statements
#version 3 main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment