sudo pip install VS pip install --user [英] sudo pip install VS pip install --user
问题描述
不记得我在哪里读过这篇文章,但是有人在这里或我正在关注的教程的评论中,一个人说:
Can't remember where I read this, but either somewhere on here or in the comments of a tutorial I was following, a person said:
'永远不要使用sudo pip install;您可能会在不知道的情况下覆盖重要的内容.使用pip install --user代替!'
'Never never ever use sudo pip install; you could overwrite important stuff without knowing it. Use pip install --user instead!'
尽管我到处都看到很多有关sudo pip install的引用,所以这个人知道他们在说什么吗,我应该避免它,或者...?
I see lots of references to sudo pip install everywhere though, so did this person know what they were talking about and I should avoid it, or... ?
推荐答案
$ sudo pip install
在python安装中全局安装软件包,即为所有用户安装.
Installs the package globally in your python installation, i.e. for all users.
$ pip install --user
安装到本地用户目录,即〜/.local/lib/python-仅您自己.
Installs to the local user directory, i.e. ~/.local/lib/python -- just you.
示例:
$ sudo pip install jupyter
$ jupyter notebook
将运行jupyter,打开网络浏览器,并允许您使用笔记本电脑.
Will run jupyter, open a web browser, allow you to work with notebooks.
$ pip install --user jupyter
$ jupyter notebook
在将本地目录添加到PATH之前,将不执行任何操作.
Will do nothing until your local directory has been added to your PATH.
最近在pypi中包含恶意代码.切勿使用sudo与pip一起安装.这与以根用户身份运行病毒相同.将本地文件夹添加到PATH或使用virtualenv.
There was recently malicious code included in pypi. Never use sudo to install with pip. This is the same as running a virus as root. Either add your local folder to your PATH or use a virtualenv.
这篇关于sudo pip install VS pip install --user的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!