Please consider editing your post and mark it as obsolete instead. Do you want to delete post?
How to run / debug programs with super user privileges
jheath
Created
What's the easiest way to run (and debug) a script/program from PyCharm with super user privleges (i.e. sudo)? FYI, I don't want to run the IDE as root.
So, that allows me to execute python via sudo. However, it appears that debugging is not an option as the Python script runs with no regards for breakpoints etc.
I am looking to do the same as the original poster. I have setup a .sh script file and added that as a python environment in the settings. However, when I run my code I get: sudo: no tty present and no askpass program specified. I am new to python and am trying to run simple web.py application which starts a CherryPy/3.1.2 WSGI Server. Via the console I start it with: sudo python service.py 85 (port 85) Any help is greately appreciated.
Would love to see this be part of the Run/Debug Configurations settings.
Are there any news on how to remote debug a python script with PyCharm?
The issue i'm facing is that I have to run the script as a specific user (through sudo su - user) - I don't have the option of creating the SSH session directly with the user that is supposed to run the script.
How would i go about doing this if i have a remote python interp. I have a raspberry pi robot setup and want to use pycharm to develop for it but python programs on the pi need sudo privileges to access the gpio pins.
i am assuming you would have a file called python-sudo.sh
Hello Justin,
You can create a shell script that would do 'sudo python " and
specify it as a Python interpreter in Settings | Python Interpreters.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
That was the first thing I tried and I get the follwoing error:
The selected file is not a valid home for Python SDK
Hello Justin,
To make PyCharm recognize it, the name of the script should start with "python".
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
So, that allows me to execute python via sudo. However, it appears that debugging is not an option as the Python script runs with no regards for breakpoints etc.
Oh, and thanks for the help. :-)
I am looking to do the same as the original poster. I have setup a .sh script file and added that as a python environment in the settings. However, when I run my code I get: sudo: no tty present and no askpass program specified. I am new to python and am trying to run simple web.py application which starts a CherryPy/3.1.2 WSGI Server. Via the console I start it with: sudo python service.py 85 (port 85) Any help is greately appreciated.
Would love to see this be part of the Run/Debug Configurations settings.
Awesome product by the way.
I will reply to my own post. You don't need to run it as sudo if you use high port numbers. I am now using 8089 and it works like a charm.
Are there any news on how to remote debug a python script with PyCharm?
The issue i'm facing is that I have to run the script as a specific user (through sudo su - user) - I don't have the option of creating the SSH session directly with the user that is supposed to run the script.
How would i go about doing this if i have a remote python interp. I have a raspberry pi robot setup and want to use pycharm to develop for it but python programs on the pi need sudo privileges to access the gpio pins.
i am assuming you would have a file called python-sudo.sh
but i am not sure what to put in it
cheers
https://esmithy.net/2015/05/05/rundebug-as-root-in-pycharm/