All of the python tuts I've been reading lately tell me to do things like this:
pip install tornado
pip install requests
And every time I do this I get hit with a permission denied
warning. But everything usually works when I sudo
.
Is sudo required? And if so, why do so many tutorial instructions fail to mention that?
In ruby we can install using Rbenv or RVM, both of which remove the need to use sudo
. Is there any equivalent in python? Or is it implied that you should always sudo
?
pip
requires permission to write the libraries to whichever directory it is using. This problem occurs when you do not have permission as a user and so pip
fails. Using sudo
gets around this problem but is not ideal.
You should not ever run code using sudo as you don't know what is inside the library, if it contains malicious code you could cause serious damage to your computer.
You can fix this problem by ensuring that you have permissions to write to the directory that pip
is set up to use.
A better alternative (as you've suggested in your comment) is to use a virtualenv, this will allow you to use pip
without the need of sudo
. Make sure you do not create this virtualenv using sudo
though as then you won't have permissions to write to it as a normal user.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句