Reputation: 23
While running a file entitled shuf-new.py
in the linux environment, the following command works when I use python 2:
./shuf.py -e bob
However, when I change the first line of my code to #!/usr/bin/python3
, I get the following error:
-bash: ./shuf-new.py: /usr/bin/python3: bad interpreter: No such file or directory
I'm not sure how to go about solving this.
Upvotes: 0
Views: 304
Reputation: 44838
While adding the shebang #!/usr/bin/python3
is a way of executing your code with Python 3, it's not the only way, and there's no guarantee it will definitely work because Python 3 may be installed in a directory other than /usr/bin
.
If Python 3 is installed on your machine (double-check that by trying to run python3
in the shell), you can always run Python 3 code with python3 your_file.py
.
If you want to use the shebang approach, use #!/usr/bin/env python3
or find the exact location of the python3
executable using which python3
.
Upvotes: 3