Goal is to run daphne on port 443.
When I run the following:
sudo daphne -e ssl:443:privateKey=/etc/ssl/mycerts/apache.key:certKey=/etc/ssl/mycerts/apache.pem myProject.asgi:application
The following error is generated:
sudo: daphne: command not found
running which sudo returns /usr/bin/sudo -- sudo is installed.
running which daphne returns /home/pi/.local/bin/daphne -- daphne is installed.
echo $PATH returns **/home/pi/.local/bin**:/lib/python3.9:/usr/local/sbin:/usr/local/bin:/usr/sbin:**/usr/bin**:/sbin:/bin:/usr/local/games:/usr/games
So, both /usr/bin and /home/pi/.local/bin are on the path.
I can run daphne on port 8001 (without sudo) without any problems (ex. daphne -b 0.0.0.0 -p 8001 myProject.asgi:application)
Why does the error command not found appear if sudo is installed, daphne is installed and both locations are on the PATH?
The trouble is when you sudo your executing the command as a different user (normally root) and
daphneisn't on that user's path. Trysudo /home/pi/.local/bin/daphne.