pip is a package manager for Python. It makes it easy to install and upgrade Python packages using the command line. Installing a Python package using pip is as easy as opening the command line and typing:
pip install -U requests
- “requests” is the package you want to install
- “install” tells pip you want to install a package. If you want to uninstall a package simply type “uninstall”.
- The “-U” flag tells pip that if the package is already installed, then upgrade it.
If you don’t already have Python installed, check out my previous post Installing Python on Windows and take care of that first.
Install pip on Windows
First off, since pip uses setuptools, we’ll need to get that installed before doing anything. Achieving this is fairly easy. You’ll just need to head over to the SetupTools pypi page, locate the link for “ez_setup.py” and download/install it. The easiest method is to right-click on the link and save it somewhere on your computer. Once it’s finished downloading, open up a command window, head over to the location where it is downloaded and run the following command:
python ez_setup.py install
When the script is finished it’ll install setuptools for you. NOTE: You’ll probably have to add the directory easy_install was installed into (C:\Python27\Scripts) to your PATH (check out my Installing Python post for a refresher) in order for Windows to find it. Then you can use setuptools to install pip by running the following command:
When everything is finished you should be able to run a pip command like the one at the top of this post and see that the requests package is installed.
Did you run into any problems? Feel free to leave a comment and I’ll do my best to help out!