I'm attempting to create a .sh file to batch a number of runs of a neural network on Python whilst on holidays.
At the moment I have been calling this from the command line:
python neural_network_trainer.py [args] I now have a .sh script written:
#!/bin/bash python neural_network_trainer.py [args] # Repeated with varied args That I am attempting to call in the same terminal as the original command line was running:
./august_hols.sh I get the following error:
File "/data/Python-3.6.9/lib/python3.6/site.py", line 177 file=sys.stderr) ^ SyntaxError: invalid syntax Where the Python install is in /data (for reasons).
Running which on the command line reports the correct Python directory set via an alias in ~/.bashrc:
alias python=/data/Python-3.6.9/bin/python3 But running which between the Bash shebang and the first python call reports /bin/python.
I've attempted to set the alias again at the start of the .sh script to no avail. I'm scratching my head as this is exact process I have used elsewhere, albeit not on this precise PC. I can copy the exact command from the top of the bash file into the terminal and it runs fine, try and call ./august_hols.sh and get the above Python error.
Where is Bash getting that path from, and why is it not using my expected route through ~/.bashrc?
#!/usr/bin/env python, depending on your setup.