AUTHORED BY
Andrew Cross
DATE
09/25/2013
CATEGORY
WORD COUNT
338
REV
0
REFERENCE IMAGE Installing modules with pip
NOTES
  1. Chances are, if you have python you have pip
  2. pip must be run from the command line, not an interpreter
SOCIAL REACH

For seasoned Python experts, using pip to install new packages is old news. However, coming from a MATLAB background, it took some research before I comfortably had my head wrapped around this process.

So what is pip, and why is it needed? It’s a package manager for Python. It makes it easy to install and uninstall different packages to your Python environment. If you’re looking for a MATLAB analogy, a module is comparable to a toolbox. Except that Python doesn’t inherently have a toolbox management. This is what pip is used for.

Install pip

Before we can install a new package, pip need to be installed. If your Python environment was established by Python(x,y), you’re in luck! If you chose to install Python as a standalone, follow the simple steps outlined here to get it up and going.

With pip installed, the next step is to open a command prompt (also called the command line) by going to the start menu, typing in cmd, and running cmd.exe. I’ve highlighted command line prompt to point out the difference between the command line and the interpreter.

If you’ve just run cmd.exe, this is the command prompt. This is where you can enter in Windows commands (ping, tracert, etc).

Command Prompt

If you were to enter the command Python to the command prompt, it would load up the Python interpreter. This is denoted by >>>. Alternatively, you could be using IDLE, or IPython, or Spyder. These are also all interpreters.

Python Interpreter

The thing is, pip operates outside of the interpreter. To run it, you must do it from the command line.

Installing a package with pip

One you’re at the command line, the syntax for is easy. It’s simply:
pip install module_name

Similarly, to uninstall a package:
pip uninstall module_name

Here’s a screenshot of me downloading wget, a packaged used to download resources from the internet. Note that it’s from the command line, not an interpreter.

Using pip to install wget

Let me know if even after that explanation you’re still getting hung up!

Profile picture of Andrew standing at the Southern-most point in the United States.
Andrew Cross

Andrew is currently a mechanical R&D engineer for a medical imaging company. He enjoys good food, motivated people, and road biking. He has still not completely come to terms with the fact he will never play center field for the Kansas City Royals.