Originally published on CodingCush.

pip is the standard package installer for Python. When a tutorial says "just pip install it", pip is the tool that downloads a ready made library and places it where your Python can use it. In this guide you will learn what pip and PyPI are, how to check whether you already have pip, and how to use install, list, show, freeze, upgrade and uninstall. Every command was tested in a real virtual environment on Python 3.12.3 with pip 24.0.

What Are pip and PyPI in Plain Words?

Think of Python as a phone with good built in apps. Sooner or later you want a new one. pip is the assistant that fetches it and installs it in the right place. The store itself is PyPI, short for the Python Package Index, where developers publish packages anyone can install with one command.

You name a package, pip talks to PyPI, downloads it and anything it depends on, and installs it into your current environment. Seconds later you can import it. The official pip documentation covers every option pip offers, but daily work needs only a handful of commands, and this article covers those.

Good news: you probably already have pip. It has shipped with standard Python installers since Python 3.4, via ensurepip.

Step 1: Check That pip Is Already Installed

Open a terminal and run:

python -m pip --version 

On Mac and Linux, use python3 -m pip --version if plain python is not available. In our test on Python 3.12.3 the answer was (your folder path will differ):

pip 24.0 from /project/.venv/lib/python3.12/site-packages/pip (python 3.12) 

That line gives the pip version (24.0), its folder, and its Python (3.12). If you see a line like this, pip is ready. If you see an error, jump to troubleshooting below.

Note the shape: python -m pip, not just pip. The -m flag runs the pip module belonging to that exact Python. Many computers hold more than one Python, and bare pip may belong to a different one, which causes the classic bug where the install "worked" but the import fails. If Python itself is missing, follow our guide to how to install Python on Windows and set up VS Code first.

Step 2: Install Your First Package

Let us install something small and safe: cowsay, which draws a cow saying whatever you type. In an active environment, run:

python -m pip install cowsay 

Here is the real output from our test:

Collecting cowsay Installing collected packages: cowsay Successfully installed cowsay-6.1 

pip found cowsay on PyPI, downloaded its wheel file (a prebuilt package format), and installed version 6.1. Now prove it works:

python -c "import cowsay; cowsay.cow('Hello from pip!')" 

Python prints a cheerful cow with your message in a speech bubble. You just completed the full loop every real project uses: name a package, let pip fetch it, import it, run it. Real packages such as requests install in exactly the same way. You can also pin an exact version, for example python -m pip install "cowsay==6.1".

Terminal window showing the real pip session tested for this article: pip 24.0 reporting its version, cowsay 6.1 installing successfully, and pip list showing cowsay and pip inside a virtual environment

The real pip session tested for this article: pip 24.0, cowsay 6.1 installed, and pip list inside a virtual environment.

Step 3: See What You Have with list, show and freeze

Installing is only half the job. You also need to inspect what an environment holds. Three commands cover this.

List everything. python -m pip list shows every installed package and its version:

Package Version ------- ------- cowsay 6.1 pip 24.0 

Show one package. python -m pip show cowsay prints the name, version, summary and the exact folder it lives in. That Location line proves which environment it went into.

Freeze the list. python -m pip freeze prints each project package as name==version:

cowsay==6.1 
python -m pip freeze > requirements.txt 

Saved like this, the output becomes requirements.txt, a recipe for your environment. Commit it, and anyone can rebuild the same setup with python -m pip install -r requirements.txt. Note that pip itself does not appear in freeze output, because freeze lists project packages, not the installer.

Step 4: Upgrade and Uninstall Packages

Upgrading is routine. Add --upgrade (short form -U):

python -m pip install --upgrade cowsay 

In our test cowsay was already current, so pip replied "Requirement already satisfied: cowsay in ./.venv/lib/python3.12/site-packages (6.1)". When a newer version exists, pip installs it instead. The same pattern upgrades pip itself: python -m pip install --upgrade pip.

Removing a package is just as clean:

python -m pip uninstall cowsay 

pip asks for confirmation, then reports "Successfully uninstalled cowsay-6.1". In scripts, add -y to skip the question. Afterwards, pip list confirmed only pip 24.0 remained.

Step 5: Always Use pip Inside a Virtual Environment

A virtual environment is a private folder holding its own Python and packages for one project. When it is active, python -m pip install puts packages into that folder only. Your system Python stays clean, Project A can keep an older library, and Project B can use the newest one, with no fights.

Create the environment once with python -m venv .venv, activate it in each new terminal, then use pip as normal. The Python Packaging Authority's guide to installing packages with pip and virtual environments walks through the same flow. For the full walkthrough, read our guide to Python virtual environments explained with venv. Think of it this way: pip is the delivery service, and the virtual environment is the address.

A natural next step is learning how your own functions accept input, in our guide to Python function arguments: positional, keyword, default, args and kwargs.

The Core pip Commands at a Glance

Task Command What it does
Check pip python -m pip --version Shows pip version and its Python
Install python -m pip install cowsay Downloads and installs a package from PyPI
Exact version python -m pip install "cowsay==6.1" Installs one specific version
List python -m pip list Shows installed packages and versions
Show details python -m pip show cowsay Shows version and install location
Freeze python -m pip freeze > requirements.txt Saves exact versions to a file
Install from file python -m pip install -r requirements.txt Installs everything in the file
Upgrade python -m pip install --upgrade cowsay Moves a package to its newest version
Uninstall python -m pip uninstall cowsay Removes a package from this environment

Keep this table nearby for daily pip work.

Common Mistakes and Troubleshooting

"pip is not recognised" or "command not found". Usually Python is not on your PATH, or bare pip fails where python -m pip works. Try python -m pip --version first. On Windows, reinstalling Python and ticking "Add Python to PATH" fixes most cases.

The externally-managed-environment error. On many newer Linux systems, installing into the system Python is blocked on purpose. Do not fight it with administrator tricks. The intended fix is Step 5: create a virtual environment and install inside it. The block protects system tools that rely on Python.

Installed, but the import fails. This is the wrong Python problem: you installed with one Python and ran code with another. Compare the Location line from pip show with your editor's Python, and reinstall with python -m pip.

Permission errors. If pip cannot write to a folder, resist rerunning as administrator or with sudo, which can damage a system Python. A virtual environment you own never needs elevated rights, so treat this as a sign you are installing in the wrong place.

Forgetting to activate. The quiet classic: the install succeeds into the global Python and your project still cannot find the package. Check for the environment name in your terminal prompt before every install.

Frequently Asked Questions

Is pip already installed with Python?

Usually, yes. pip has shipped with the standard installers since Python 3.4 via ensurepip. Check with python -m pip --version.

What is the difference between pip and PyPI?

PyPI is the online library. pip is the tool that downloads packages from PyPI and installs them. One is the shop, the other is the assistant.

Should I type pip or python -m pip?

Prefer python -m pip. It installs packages for the exact Python you named, preventing the most common confusion on multi Python machines.

Where do pip packages get installed?

Into the site-packages folder of the active environment. Run python -m pip show with a package name to see its Location.

What is requirements.txt for?

It lists your project's packages with exact versions, created by pip freeze. Anyone can rebuild the same environment with pip install -r requirements.txt.

Conclusion

pip is not a mysterious extra tool. It is the standard installer that already travels with Python, fetching packages from PyPI so you can stand on the work of other developers. Check it with python -m pip --version, keep each project inside its own virtual environment, and save your requirements.txt. Then "just pip install it" becomes an instruction you enjoy.