How to Install Libraries and Enable the pip Installer in Python

Python comes with a bunch of standard modules. My favorites are shutil, glob, datetime, time, os (operating system), re (regular expressions) and webbrowser. The standard library is loaded.

Inevitably, you’ll want to install new libraries from Python’s rich ecosystem of external modules. Enter pip, Python’s handy package manager and people’s champion.

This post will teach you some Python history, show how to install pandas, and help you troubleshoot problems if it’s not working. You’ll find Windows and Linux commands for venv setup (recommended). With pip, you’ll feel like Neo when installing new modules. Any skill is at your fingertips. It’s like learning kung fu. There’s probably a library for that!

i know kung fu

First, Some Python Version Caveats + History

Python 2 reached end of life on January 1st, 2020. Python 2 has officially been sunset.

Python comes with pip now, no setup is required. But certain versions such as Python 3.2 or the Python 2.7 that came stock on my improbably still functioning 2008 black Macbook, for example, may not have it installed.

In December 2021, Python 3.6 reached “end of life phase”.

Python 3.6 is “now effectively frozen”. Read more in PEP 494. Consider using a newer version like Python 3.11! (Released Oct. 2022)

Per the pip installation documentation, circa 2018:

“pip is already installed if you are using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from…

TLDR: the pip docs say to use Python 3.7 to 3.11. Why not use the lightning fast Python 3.11!

Enter This in Your Terminal

python -m pip install pandas

Pandas is a super useful library for wrangling spreadsheet data, AKA “tabular” data. If successful, you should see activity that looks similar to the below screenshot, where I am installing openpyxl, an additional Python Excel library you’ll likely want. You are good to go! This is the part where you get to feel like Neo! See Installing Python Modules in the Python Documentation for more detailed instructions.


Psst! To view all your installed libraries, enter:

pip list

You can list your outdated packages with the –outdated argument:

pip list --outdated

Supplementary Resources

Congrats on figuring out how to install packages with pip, have fun!

Having issues? Use the ensurepip command.

This command will install and upgrade pip to the newest version. New in Python 3.4:

python -m ensurepip --upgrade

“The ensurepip package provides support for bootstrapping the pip installer into an existing Python installation or virtual environment. This bootstrapping approach reflects the fact that pip is an independent project with its own release cycle, and the latest available stable version is bundled with maintenance and feature releases of the CPython reference interpreter.”

ensurepip Python Documentation

Sidebar: the pip resolver

The pip dependency resolver was newly released in 2020 as a command line argument flag by the pip team. It has since been changed to the default dependency resolver:

pip resolver

Above: upgrading websockets (requires Python >= 3.7) with arguments

If you’re still having problems…

Ensure Python can run in any directory on Windows.

To check if you can run Python anywhere: open command prompt, type python and hit enter. Type quit() to exit the interpreter, then use the cd command to change the directory and type python again. If the python interpreter runs in a few different file path locations, you’re good to go. If this doesn’t work, you may need to do the following:


  1. Go to “Advanced System Settings”.
  2. Select “Environment Variables”.
  3. Under “System Variables”, edit your “path” variable.
  4. Paste in c:\Python38; and click “ok”, then “apply”. Make sure you edit this to match your Python version if it’s not Python 3.8.

You should follow best practice and create a virtual environment before installing libraries. venv or virtualenv will help you out. To create with venv:

python3 -m venv add_env_name_here

After your environment is created, activate it with the first command below, then install a library on Ubuntu Linux:

  1. cd add_env_path_here/bin & source activate
  2. python -m pip install pandas

Alternatively, on Windows computers:

  1. cd add_env_path_here\scripts & activate
  2. python -m pip install pandas

Know your OS.

If you’re interested in installing pip on Linux, try here. For Mac, try here. Windows, Mac and Linux sometimes use different prefixes (e.g. python, py, python3) to run a python script. Which leads me to my next point…

Getting the prefix right can be tricky.

Since this was written, I moved to Python 3.8. When I first moved from Python 2 to 3 on Windows, I somehow accidentally configured the following behavior: entering python ran a .py file with Python 2. Whereas, entering py ran a .py file with Python 3.

In the install command, the prefix is a reference to your Python executable. You may just need to alter your prefix to call it correctly. Here are some to try in place of “python”. Observe what happens when you run these command variations. Good luck!

python3 -m pip install pandas

python3.11 -m pip install pandas

py -m pip install pandas

pip3 install pandas

How to Manually Enable the pip Installer

The rest of this post may be useful to you if you are:

  1. Working on legacy Python 2 code or Python 3.3 or lower for which pip is not installed.
  2. Seeking to fix a faulty pip install that is not working properly.
  3. Curious to know how to manually set up pip.

Assumes Python is already installed. If you’re running Windows 10, I found it easy to install Python from the Windows store.

Download the file.

Go to the link, right click the page and “Save As” a .py file to download. Then place the file where you want to access it. I placed mine in C:\Python27\Lib\site-packages

You could also download the file with curl:

curl -o 

If you are not sure where your site-packages folder is, type python -m site into command prompt for file path ideas.

Run the file.

Using command prompt’s cd command with a Windows “&” operator to run the Python file in a Windows command prompt:

cd c:\Python27\Lib\site-packages & python

Or Linux terminal:

cd /Python27/Lib/site-packages && python

You should see some activity in command prompt that shows installation/updating of “setup” and “wheel”. When it finishes, you have installed pip.

Type into command prompt at the same location:

python -m pip install requests 

This should install the Requests module into your Python libraries. Requests is an http module which is highly regarded almost universally by the Python community.

Thanks for reading! Check out these other posts with pip installed library examples:

Fix Grammar and Spelling with language_tool_python and textblob

gooey – GUI library

tweepy – Twitter library

A Guide to Making HTTP requests

Plotting Datasets Using Jupyter, Pandas and Matplotlib

8 thoughts on “How to Install Libraries and Enable the pip Installer in Python

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.