Do I need sudo when running pip / easy_install?

All the python posts I read recently tell me that I am doing things like this:

pip install tornado pip install requests 

And every time I do this, I get a permission denied warning. But everything works when I sudo .

Is sudo required? And if so, why don't so many instructions mention it?

In ruby, we can install Rbenv or RVM, both of which eliminate the need to use sudo . Is there an equivalent in python? Or is it meant that you should always sudo ?

+6
source share
1 answer

pip write permission is required depending on which directory it uses. This problem occurs when you do not have permission as a user, and therefore pip fails. Using sudo circumvents this problem but is not ideal.

You should not run the code with sudo, since you do not know what is inside the library if it contains malicious code that could seriously damage your computer.

You can fix this problem by indicating that you have write permissions to the directory used by pip .

The best alternative (as you suggested in your comment) is to use virtualenv, this will allow you to use pip without the need for sudo . Make sure that you do not create this virtualenv using sudo , although, as then, you will not have write permissions to it as a regular user.

+8
source

Source: https://habr.com/ru/post/974751/


All Articles