Hey there everyone ๐1!
To all the Python users out there, we've all used pip in out life, right?
๐ฎ History
pip
is the de facto and recommended package-management system written in Python and is used to install and manage software packages. It connects to an online repository of public packages, called the Python Package Index.
It was released on 4 April 2011 with the MIT license.
Over the years pip
was changed rapidly! A lot of ground-breaking changes were introduced in the recent few years.
๐ฆ Updating pip
We all know how to update pip a package in pip, right? We just do
pip install -U <package_name>
But, pip too itself is an package, but it cannot be updated with the same command -
pip install -U pip
NO! It's wrong!
๐ฒ Explanation
Consider you are running an app. Now if I delete the app and reinstall a new version of the same app while the app is running, is it possible? NO! If I delete the source while it is running it will no longer exists to work, so abnormally quit itself. Thus, pip added this safety check to run itself under python as a module. ๐งโ๐ป Quite amazing and next-level thinking right?
I too recently realised this while fix a bug in the docs of tenserflow.
Comment for #2141
It is a well know fact that pip cannot update itself while running itself
Is this for Windows? It's fine on other platforms. Apologies if this is obvious to everyone running Windows, but could you provide a link for context?
I use windows so I haven't tested it on other platforms, but yeah, on windows, the command returns an error.
Just for the demonstration, I downgraded my pip version to 22.1
and then tried to update pip with the command pip install -U pip
...
Now, as you see, for upgrading pip it has to be run under python as a module. I strongly believe it has to be the same case under other OS's.
๐ฎ Explanation
Consider you are running an app. Now if I delete the app and reinstall a new version of the same app while the app is running, is it possible? NO! If I delete the source while it is running it will no longer exists to work, so abnormally quit itself. Thus, pip added this safety check to run itself under python as a module.
My only suggestion is that
python3
is used as the binary elsewhere in the instructions, so we should be consistent, otherwise users with multiple installations may end up being surprised.
By default, python3
is not an executable on windows. If someone installs python from the official website, the default command becomes python
itself. Now, if someone on windows enters the command python3
in the pwsh
, it open microsoft store and opens the python3 installation page.
Please lemme know if I should change everything to python
or python3
.
๐ Connect with me
-
Mail -
akashpattnaik.github@gamil.com
-
Github -
BLUE-DEVIL1134
-
Twitter -
akash_am1
Top comments (0)