nO_OnE_910 nO_OnE_910 - 2 months ago 19
Linux Question not working in PyCharm (linux)

Here's the program:

if == 'posix' and getpass.getuser() != 'root':
from subprocess import call

call(["sudo", sys.executable, os.path.realpath(__file__), "--root-install"])

When I run it from the terminal it works fine:

> [sudo] Password for user:

But when I run it from PyCharm the terminal just stays blank.

I have also tried setting
stdin=sys.stdin, stdout=sys.stdout
manually, but that did not change anything.

What am I doing wrong here?


PyCharm and IDEs generally don't like getpass-like inputs. Since sudo asks for the password in such a way, it's not runnable from a redirected IDE console.

Redirecting stdin from Popen won't change anything either.

Workaround: run the sudo command from a terminal. Example with xterm (sorry, I don't know much about nowadays terminals):

call(["xterm","-e","sudo", sys.executable, os.path.realpath(__file__), "--root-install"])