What are the risks of running 'sudo pip'?

前端 未结 4 2178
猫巷女王i
猫巷女王i 2020-11-22 07:52

Occasionally I run into comments or responses that state emphatically that running pip under sudo is \"wrong\" or \"bad\", but there are cases (inc

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 08:15

    Using pip that way means you trust it to the level you allow it to make anything to your system. Not only pip, but also any code it will download and execute from sources you may not trust and that can be malicious.

    And pip doesn't need all that privileges, only the write access to specific files and directories. If you can't use your system's package manager and do not want to go the virtual environment way, you may create a specific user that has write privilege to the python installation directory and use it for pip. That way you better control what can pip do and not do. And you can use sudo -u for that!

提交回复
热议问题