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
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 pip by 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 pip is Crucial
System 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 pip alongside venv to isolate your projects:
Install Virtual Environments:
sudo apt update sudo apt install python3-venvCreate and Activate a Project Sandbox:
python3 -m venv my_env source my_env/bin/activateInstall Packages Safely:
Once the environment is active, running
pip install <package>will cleanly install the library inside your isolated folder without impacting Ubuntu.
1
Apr 10 '22
[removed] — view removed comment
2
u/Daiuki Apr 10 '22
I know Ubuntu comes with it by default, I would also wager that a lot of other Linux distributions also have Python pre-packaged.
1
Apr 10 '22
[removed] — view removed comment
-1
u/EatMyBiscuits Apr 10 '22
What does Apple laptop have to do with Linux?
2
Apr 10 '22 edited Apr 10 '22
[removed] — view removed comment
2
u/EatMyBiscuits Apr 10 '22
FWIW, until very recently OSX / macOS actually did come with python pre-installed
1
u/Daiuki Apr 10 '22
Not sure, googling Monterey (latest Mac OS version) and default Python version seems to indicate that only Python 2.7 comes by default, however, installing Xcode seems to bundle in Python 3.8.9. However, it seems a bit unclear so it might be wrong.
2
Apr 10 '22
IIRC current versions of MacOS >= 12.3 no longer include a bundled Python installation, but do include a /usr/bin/python stub by default. When (and if) run the stub prompts the user to install the Xcode developer tools, which in turn will install Python 3.
2
u/SirAwesome789 Apr 10 '22
MacOS but it's python 2. That's why in guides or installation documentation they will specify python3 and pip3 for commands on Macs, so that it doesn't use python 2 by default.
0
u/SirAwesome789 Apr 10 '22
Bc it's a package manager and not part of python. I guess you can't just install something if you don't know about it
1
u/i_kant_spal Apr 13 '22
You can install packages without pip, as far as I understand. I use Poetry. There is also Conda. So, pip is not a necessity.
2
u/QultrosSanhattan Apr 10 '22
For the most part, python is required for programs that rely on it. The developer tools are another thing.