Debugging in pyCharm with sudo privileges?

前端 未结 9 574
粉色の甜心
粉色の甜心 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:53

    I follow the instructions here and success. But there is a problem that the PYTHONPATH is not valid when you use sudo. So when you edit with

    sudo visudo -f /etc/sudoers.d/python
    

    add that:

    user host = (root) NOPASSWD:SETENV: /home/yizhao/anaconda3/bin/python
    

    also your script should be:

    #! /bin/bash
    sudo PYTHONPATH=$PYTHONPATH /home/name/anaconda3/bin/python "$@"
    

提交回复
热议问题