Debugging in Pycharm with Sudo Privileges

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).

How can I debug a python script from command line using PyCharm?

Short answer: Tools> Attach to Process...

Long anser:

  1. Put a following line at very first of your code

    input("press Enter to continue")
  2. Launch your code in shell

    myscript.py --input1 ./dir/file1.txt --input2 ./dir/file2.txt
  3. Open Pycharm and use it to open your myscript.py. Set break points at anywhere you like to debug. Select Tools> Attach to Process... and select the process that myscript.py is running.

  4. Come back to the shell of myscript.py and hit Enter

Trouble you may get: ptrace don't have permission of doing something

Solution:

sudo su
echo 0 > /proc/sys/kernel/yama/ptrace_scope

or you can set 0 directly in

/etc/sysctl.d/10-ptrace.conf

How to run python file with admin rights in pycharm

Startup pycharm as Administrator then all scripts will be ran as administrator.

From Windows start menu right click the Pycharm shortcut and select 'Run as administrator.' Optionally create a short and change the options to always Run as Administrator under the "Compatibility" tab.

IntelliJ - Running Program as Sudo

I came out with an answer and wanted to share it just in case anyone else runs into this. To solve the problem, I took my cue from what I do with QT & QT Creator when doing network programming.

On OSX, I opened up a terminal window and cd'd down to/Applications/IntelliJ IDEA 9.0.3.app/Contents/MacOS. There you will find a file called idea which launches the IDE. I ran that as sudo (sudo ./idea). That took care of permissions on anything Intellij launched and I could debug and step through my code as needed.

sudo /Applications/IntelliJ IDEA 9.0.3.app/Contents/MacOS/idea 

Since this is a dev machine and I am in control of it security is not an issue in this case.

Hope it helps someone else out.

PyCharm For Windows: Debugging Down / Up With Selection Executes Present Line

A workaround for the moment is, to deactivate the option Show value tooltip on code selection (in Settings/Debugger/Dataview).

PyCharm error: [Errno 13] Permission denied

It looks like you need to give your interpretter root permissions. There is a tutorial here on how to do this



Related Topics



Leave a reply



Submit