Skip to content

Commit 1515aef

Browse files
committed
Replace python3 with python command for flexibility
1 parent b77c64d commit 1515aef

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

myCarbonFootprint.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,34 @@ parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
1313
cd "$parent_path"
1414

1515
# The only requirement for the module is to start python 3.7 or later
16-
module load miniconda/3
16+
#module load miniconda/3
17+
18+
# Test if the virtualenv GA_env already exists, and if not, creates it.
19+
if [ ! -f GA_env/bin/activate ]; then
20+
echo "Need to create virtualenv"
21+
python -m venv GA_env
22+
source GA_env/bin/activate
23+
pip3 install -r requirements.txt
24+
else
25+
echo "Virtualenv: OK"
26+
source GA_env/bin/activate
27+
fi
1728

1829
# Test if the python version is at least 3.7
19-
version_major=$(python3 -c 'import sys; print(sys.version_info[0])')
20-
version_minor=$(python3 -c 'import sys; print(sys.version_info[1])')
30+
version_major=$(python -c 'import sys; print(sys.version_info[0])')
31+
version_minor=$(python -c 'import sys; print(sys.version_info[1])')
2132
if (( $version_major < 3 )); then
22-
echo "The command python3 needs to refer to python 3"
33+
echo "The command python needs to refer to python 3"
2334
exit 1
2435
fi
2536

2637
if (( $version_minor < 7 )); then
27-
echo "The command python3 needs to refer to python3.7 or higher."
38+
echo "The command python needs to refer to python3.7 or higher."
2839
exit 1
2940
fi
30-
3141
echo "Python versions: OK"
3242

33-
# Test if the virtualenv GA_env already exists, and if not, creates it.
34-
if [ ! -f GA_env/bin/activate ]; then
35-
echo "Need to create virtualenv"
36-
python3 -m venv GA_env
37-
source GA_env/bin/activate
38-
pip3 install -r requirements.txt
39-
else
40-
echo "Virtualenv: OK"
41-
source GA_env/bin/activate
42-
fi
4343

4444
# Run the python code and pass on the arguments
4545
#userCWD="/home/ll582/ with space" # DEBUGONLY
46-
python3 GreenAlgorithms_global.py "$@" --userCWD "$userCWD"
46+
python GreenAlgorithms_global.py "$@" --userCWD "$userCWD"

0 commit comments

Comments
 (0)