What are the risks of running 'sudo pip'?

前端 未结 4 2175
猫巷女王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:12

    Besides obvious security risks (which I think are in fact low when you install software you know) brought in other answers there is another reason. Python that comes with the system is part of this system and when you want to manage system you use tools designated for system maintenance like package manager in case of installing/upgrading/uninstalling software. When you start to modify system's software with third party tools (pip in this instance) then you have no guarantee about the state of your system. Yet another reason is that sudo can bring you problems you wouldn't have a chance or have a very small chance to have otherwise. See for example Mismatch between sys.executable and sys.version in Python

    Distros are aware of this problem and try to mitigate it. For example Fedora – Making sudo pip safe and Debian – dist-packages instead of site-packages.

提交回复
热议问题