If you're not operating in a Python 3 virtual environment, and you want to run scripts using Python 3 there are two easy ways.
Use a shebang
At the top of your script you can include a shebang like so:
and make sure the script is executable:
chmod +x path/to/script.py
Now when you run:
it will be run using Python 3. More specifically, the program loader sees the shebang line and knows to call the
python3 program and pass in
path/to/script.py as the first argument.
Using python3 directly
Another simple way is to just call
This will ensure your script is run using Python 3 rather than the system python.