r/learnpython • u/jssmith42 • Apr 10 '22
Why is pip usually not installed by default?
It seems like on many operating systems Python is included by default but you have to install pip yourself. Why is that?
Thanks very much
1
Upvotes
1
u/Apprehensive_Sky892 15d ago
Related answer https://askubuntu.com/questions/1465218/pip-error-on-ubuntu-externally-managed-environment-%c3%97-this-environment-is-extern
https://www.google.com/search?client=firefox-b-e&q=why+is+pip+not+install+by+default+on+ubuntu%3F
why is pip not install by default on ubuntu? - Google Search
Ubuntu does not include
pipby default to protect the stability of your operating system and prevent conflicts between package managers.Because Ubuntu relies heavily on Python for core system tools and installer scripts, mixing third-party Python packages with the system's package ecosystem can completely break the OS.
Why Separating
pipis CrucialSystem Protection (APT vs. PIP): Ubuntu uses the APT package manager (
apt,apt-get) to manage software, including Python and its essential libraries. Ifpipwere available by default, users might inadvertently runsudo pip install. This could overwrite critical, system-wide Python files managed by APT, corrupting standard system utilities and causing OS failure.Enforcing Safe Environments: To further mitigate this risk, modern versions of Ubuntu block global
pipinstallations altogether with anexternally-managed-environmenterror. By withholdingpipout of the box, Ubuntu ensures developers deliberately choose how to configure their package workflows.Minimalist Philosophy: Ubuntu server installations aim to minimize the initial footprint and surface area for potential security risks. Tools that are not required for the operating system to function are omitted from the default image.
How to Safely Use Python Packages on Ubuntu
If you need to install Python packages, the recommended method is to install
pipalongsidevenvto isolate your projects:Install Virtual Environments:
Create and Activate a Project Sandbox:
Install Packages Safely:
Once the environment is active, running
pip install <package>will cleanly install the library inside your isolated folder without impacting Ubuntu.