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.
source share