How to Always run Python 3 from Bash
Given a directory that contains:
We can create a runme.sh
file to always make sure we are running python 3
.
Create a shell script
Create a file called runme.sh
and put the following code in:
|
|
Now instead of running python app.py
or python3 app.py
, you can simply run sh runme.sh
.
Why is this useful?
This is very useful when distributing applications onto servers where the environment is not containerised.
Additional tips
You can also get the python version:
Or by calling the version argument:
For tips on how to containerise an application, take a look at The Docker Quickstart Guide for Developers.