Debugging in pyCharm with sudo privileges? Debugging in pyCharm with sudo privileges? linux linux

Debugging in pyCharm with sudo privileges?


Create a shell script that does "sudo python" and forwards the arguments, and configure that script as a Python interpreter in PyCharm.

Name of this shell script should start with python (source: http://forum.jetbrains.com/message/PyCharm-424-3).


In PyCharm new version, it has a configure to run Python interpreter in root, no need workaround. See picture below. Check to checkbox: Execute code using this interpreter with root privileges via sudo

enter image description here


For what it's worth, I've managed run a python script with sudo priviledges (on Ubuntu 16.04) like this:

  1. In the very first line in the script, define the interpreter like this:

    #!/usr/bin/sudo python

  2. Make the script executable:

    chmod +x myscript.py

  3. Run the script directly, without specifying the python interpreter yourself:

    ./myscript.py

  4. The script will ask for sudo password and continue running with elevated priviledges.