简体   繁体   中英

how to use sudo python -m on ubuntu (20.04)

I'm trying to do a python -m flask run command at the terminal because the interpreter packages I'm using for my projects reside in the.local user directory (which 'python -m' seems to call but simply using 'python' does not). I'm trying to use this to open port 80 though (a privileged port) and thus need to invoke root, but when I try 'sudo python -m flask run..." I get the "flask module doesn't exist" type of error. How do I run this command as root and still use the.local path for my python modules?

By default sudo runs commands in different environment.
You can ask sudo to preserve environment with -E switch.

sudo -E <command>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM