问题描述
我最近在一篇帖子中评论,我读到建议不要使用'sudo pip'来安装某些项目.有人可以弄清这是为什么,以及不利/不利之处是什么?谢谢!
In a post I was reviewing recently, I read that it's advised not to use 'sudo pip' to install certain items. Can someone clarify why this is and what the downsides/upsides are? Thanks!
推荐答案
您的操作系统具有Python解释器,可运行由包管理器控制的Python软件 ,可以是apt,yum或App Store.安装到系统Python安装中的任何Python软件包都是此类软件或该软件本身的依赖项.
Your OS has a Python interpreter to run Python software controlled by your package manager, be it apt, yum, or App Store. Any Python package installed to the system Python installation are dependencies of such software, or that software itself.
通过在系统Python中安装或更新软件包,您可以破坏该软件.同样,您的修改将被下次需要您覆盖的依赖项(已升级")的更新所覆盖(通常在您安装具有多个依赖项的东西时会发生).这可能会在最不利的时刻咬你.
By installing or updating packages in your system Python, you can break that software. Also, your modifications would be overwritten with the next update of something that required a dependency you've overwritten ("upgraded"), which often occurs when you install something with many dependencies. This can bite you at the most inopportune moment.
如果您珍惜时间和理智,请始终使用virtualenv
或您喜欢的包装器.每个项目最好有一个virtualenv,并为AWS CLI之类的东西提供单独的virtualenv. 从不 sudo pip install
任何适合您的开发.
If you value your time and sanity, always use virtualenv
or your favorite wrapper over it. Preferably have one virtualenv per project, and separate virtualenvs for stuff like AWS CLI. Never sudo pip install
anything for your development.
这篇关于为什么使用sudo pip是个坏主意?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!