Debugging in pyCharm with sudo privileges?

前端 未结 9 572
粉色の甜心
粉色の甜心 2020-12-31 04:27

I\'ve tested code that requires root access in pyCharm by running sudo pycharm.sh but this is not the way I would recommend of doing so.

I

9条回答
  •  自闭症患者
    2020-12-31 04:36

    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.

提交回复
热议问题