The pip command is the default package installer for Python, used to install, update, and manage software packages from the Python Package Index (PyPI). Most Python distributions (Python 3.4+ and 2.7.9+) include pip by default, though on Linux systems with Python 3, the command is often explicitly named pip3.
To execute commands, users can typically run pip <command> (e.g., pip install flask) or, more reliably across all environments, python -m pip <command> (e.g., python -m pip install flask).
Common pip Commands and Options
Install Packages: Use
pip install <package-name>to install the latest version, orpip install <package-name>==<version>for a specific version.Upgrade Packages: The
-Uor--upgradeflag updates existing packages (pip install -U <package-name>).List Installed Packages:
pip listdisplays installed packages in a table, whilepip freezeoutputs them in a format suitable forrequirements.txtfiles.Uninstall Packages: Use
pip uninstall <package-name>to remove a package, adding the-yflag to skip confirmation prompts.Search and Check:
pip search <term>finds packages by name, andpip checkverifies that installed dependencies are compatible.Requirements Management:
pip install -r requirements.txtinstalls all packages listed in a file, whilepip freeze > requirements.txtgenerates such a file from the current environment.
Platform-Specific Usage
On Windows, if pip is not recognized, users may need to use py -m pip or add the Python Scripts directory to their system PATH. On Linux and macOS, pip3 is often the preferred command for Python 3 environments, while python3 -m pip ensures the correct Python version is targeted regardless of the system alias.
python - How to run Pip commands from CMD - Stack Overflow
How to...pip install?
python - bash: pip: command not found - Stack Overflow
installation - How can i use pip command correctly in Python? - Stack Overflow
Videos
ยป pip install pip
Little side note for anyone new to Python who didn't figure it out by theirself: this should be automatic when installing Python, but just in case, note that to run Python using the python command in Windows' CMD you must first add it to the PATH environment variable, as explained here.
If you have the Python launcher installed, in such case instead of typing python in the console you can type py. Whether or not one or both commands are available depends on the choices you made during installation.
To execute Pip, first of all make sure you have it installed, so type in your CMD:
> python
>>> import pip
>>>
The above should proceed with no error. Otherwise, if this fails, you can look here to see how to install it. Now that you are sure you've got Pip, you can run it from CMD with Python using the -m (module) parameter, like this:
> python -m pip <command> <args>
Where <command> is any Pip command you want to run, and <args> are its relative arguments, separated by spaces.
For example, to install a package:
> python -m pip install <package-name>
Newer versions of Python come with py, the Python Launcher, which is always in the PATH.
Here is how to invoke pip via py:
py -m pip install <packagename>
py allows having several versions of Python on the same machine.
As an example, here is how to invoke the pip from Python 2.7:
py -2.7 -m pip install <packagename>
Never thought I'd need to ask this question as a CCNA and Network+ holder, I guess Python has decided to make the simple act of a pip install THIS difficult, wow! I have Python installed as well as Virtual Studio Code. I try this from command prompt
pip3 install requests File "<stdin>", line 1 pip3 install requests ^^^^^^^
And that's all I get, again and again and again. So I try this in the Visual Studio terminal:
pip3 : The term 'pip3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
-
pip3 install requests
-
+ CategoryInfo : ObjectNotFound: (pip3:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Mind blowing stuff here. I JUST want to be able to pip install. I've also tried just using "pip" and leaving out the 3. What mountains must I move to perform such a basic task? I
Factsheet
Why not just do sudo easy_install pip or if this is for python 2.6 sudo easy_install-2.6 pip?
This installs pip using the default python package installer system and saves you the hassle of manual set-up all at the same time.
This will allow you to then run the pip command for python package installation as it will be installed with the system python. I also recommend once you have pip using the virtualenv package and pattern. :)
2020 Update:
For current Debian/Ubuntu, use
apt-get install python3-pip
to install pip3.
Old 2013 answer (easy_install is now deprecated):
Use setuptools to install pip: sudo easy_install pip
(I know the above part of my answer is redundant with klobucar's, but I can't add comments yet), so here's an answer with a solution to sudo: easy_install: command not found on Debian/Ubuntu: sudo apt-get install python-setuptools
Also, for python3, use easy_install3 and python3-setuptools.
For Python 3, use apt-get install python3-pip.


