sudo: python: command not found
...other approach.
when I got to this post, I was just looking to run:
python -m spylon_kernel install
as I ran the command above, I got a message telling me to use sudo
in addition to what I was typing, such as
sudo python -m spylon_kernel install
as I did it, I got the 'sudo: python: command not found' message from console, and adding --user such as:
python -m spylon_kernel install --user
was simply enough to get it done.
Notice that I did not use
sudo
command within the last command.
Your /etc/sudoers
is explicitly configured to override your user's path with a known, secure one.
That said, if you want to always path the user's PATH through, you can easily override sudo
with a function that will do this (installed in your ~/.bashrc
or similar to make it persistent):
psudo() { sudo env PATH="$PATH" "$@"; }
thereafter, psudo python
will use the same python
interpreter that would be found in the PATH.
If you really want to override the sudo
command itself, that's doable too:
sudo() { command sudo env PATH="$PATH" "$@"; }
The command
builtin prevents the function from recursing (calling itself).
If you don't want to modify your bashrc, you can always do this:
sudo env "PATH=$PATH" python something