Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1251

Python • Re: Running Sudo Causes My Code to Not Work

$
0
0
But then when I ran sudo (as I need to use sudo for some other stuff later on), the code would immediately stop.
Are you running in a Python Virtual Environment? If not then by running under SUDO Python looks at system rather than user Python modules you've installed with PIP.

As someone else mentioned, don't pipe to /dev/null and you will likely see Import errors.

Personally, I would investigate putting your project into a Virtual Environment so you only need to load the modules one. I would explore what it means to run SUDO under that.

Try Posting to the Python Forum https://forums.raspberrypi.com/viewforum.php?f=32

Statistics: Posted by DS256 — Mon Jun 24, 2024 7:02 pm



Viewing all articles
Browse latest Browse all 1251

Trending Articles