How to make python shebang use python3?
Solution 1:
env
cannot find python because env is searching python in your PATH
, not on any shell builtin, or alias or function. As you have defined python as using EXPORT
env won't find it, it will search through 'PATH' and will resolve python to /usr/bin/python (which is python2 and not present in the system).
You can check all the available locations of executable python, in bash, do:
type -a python
You are unlucky if you want to use an alias in shebang as by definition, shebang needs to be an full path to the interpreter executable, which the env should resolve python to when you use /usr/bin/env python
. To interpret the script using python3 use the shebang:
#!/usr/bin/env python3
Solution 2:
Since OP does not install python2 and doesn't need /usr/bin/python as python2, I'm suprised that no one mentioned the most simple solution.
You just symbolic link python to python3 with sudo ln -s python3 /usr/bin/python
, and it will work.
Or, config the alternatives as mentioned in the comment(3.6 if you're using Ubuntu 18.04 on WSL):
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 100