Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is using sudo pip a bad idea? [duplicate]

Tags:

python

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!

like image 402
j413254 Avatar asked Jan 25 '23 02:01

j413254


2 Answers

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.

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.

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.

like image 50
9000 Avatar answered Feb 04 '23 05:02

9000


sudo <anything> is a bad idea because it requires root password/privilege.

Especially when it is not needed.

You may have a rogue pip script sitting somewhere in your path, for example, that can break your system.

like image 23
sureshvv Avatar answered Feb 04 '23 05:02

sureshvv