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>
Answer from Marco Bonelli on Stack OverflowLittle 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>
python - How do I install pip on Windows? - Stack Overflow
How to...pip install?
python - how to install pip on windows - Stack Overflow
Beginner trying to install/import pip on Windows 11
Videos
Python 3.4+ and 2.7.9+
Good news! Python 3.4 (released March 2014) and Python 2.7.9 (released December 2014) ship with Pip. This is the best feature of any Python release. It makes the community's wealth of libraries accessible to everyone. Newbies are no longer excluded from using community libraries by the prohibitive difficulty of setup. In shipping with a package manager, Python joins Ruby, Node.js, Haskell, Perl, Go—almost every other contemporary language with a majority open-source community. Thank you, Python.
If you do find that pip is not available, simply run ensurepip.
On Windows:
py -3 -m ensurepipOtherwise:
python3 -m ensurepip
Of course, that doesn't mean Python packaging is problem solved. The experience remains frustrating. I discuss this in the Stack Overflow question Does Python have a package/module management system?.
Python 3 ≤ 3.3 and 2 ≤ 2.7.8
Flying in the face of its 'batteries included' motto, Python ships without a package manager. To make matters worse, Pip was—until recently—ironically difficult to install.
Official instructions
Per https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip:
Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt:
python get-pip.py
You possibly need an administrator command prompt to do this. Follow Start a Command Prompt as an Administrator (Microsoft TechNet).
This installs the pip package, which (in Windows) contains ...\Scripts\pip.exe that path must be in PATH environment variable to use pip from the command line (see the second part of 'Alternative Instructions' for adding it to your PATH,
Alternative instructions
The official documentation tells users to install Pip and each of its dependencies from source. That's tedious for the experienced and prohibitively difficult for newbies.
For our sake, Christoph Gohlke prepares Windows installers (.msi) for popular Python packages. He builds installers for all Python versions, both 32 and 64 bit. You need to:
- Install setuptools
- Install pip
For me, this installed Pip at C:\Python27\Scripts\pip.exe. Find pip.exe on your computer, then add its folder (for example, C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:
pip install httpie
There you go (hopefully)! Solutions for common problems are given below:
Proxy problems
If you work in an office, you might be behind an HTTP proxy. If so, set the environment variables http_proxy and https_proxy. Most Python applications (and other free software) respect these. Example syntax:
http://proxy_url:port
http://username:password@proxy_url:port
If you're really unlucky, your proxy might be a Microsoft NTLM proxy. Free software can't cope. The only solution is to install a free software friendly proxy that forwards to the nasty proxy. http://cntlm.sourceforge.net/
Unable to find vcvarsall.bat
Python modules can be partly written in C or C++. Pip tries to compile from source. If you don't have a C/C++ compiler installed and configured, you'll see this cryptic error message.
Error: Unable to find vcvarsall.bat
You can fix that by installing a C++ compiler such as MinGW or Visual C++. Microsoft actually ships one specifically for use with Python. Or try Microsoft Visual C++ Compiler for Python 2.7.
Often though it's easier to check Christoph's site for your package.
-- Outdated -- use distribute, not setuptools as described here. --
-- Outdated #2 -- use setuptools as distribute is deprecated.
As you mentioned pip doesn't include an independent installer, but you can install it with its predecessor easy_install.
So:
- Download the last pip version from here: http://pypi.python.org/pypi/pip#downloads
- Uncompress it
- Download the last easy installer for Windows: (download the .exe at the bottom of http://pypi.python.org/pypi/setuptools ). Install it.
- copy the uncompressed pip folder content into
C:\Python2x\folder (don't copy the whole folder into it, just the content), because python command doesn't work outsideC:\Python2xfolder and then run:python setup.py install - Add your python
C:\Python2x\Scriptsto the path
You are done.
Now you can use pip install package to easily install packages as in Linux :)
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
I recommend you to uninstall python and then reinstall it again. In the installation window, use custom installation and check all the option which includes pip and also check to add pip to your environment variables.
In Windows 10, you need to add pip to the PATH.
This post should solve your issue: 'pip' is not recognized as an internal or external command
» pip install pip