🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

pip Command

Beginner Package Management man(1)

Install Python packages from PyPI

👁 9 views 📅 Updated: Mar 15, 2026
SYNTAX
pip [OPTION]... COMMAND [PACKAGE]

What Does pip Do?

pip is the package installer for Python. It downloads and installs Python packages from the Python Package Index (PyPI) and other repositories. pip manages Python dependencies for applications and development.

pip handles package installation, upgrades, removal, and dependency resolution. It can install from PyPI, Git repositories, local directories, and requirements files.

Modern Python best practice is to use pip within virtual environments (python -m venv) to isolate project dependencies and avoid conflicts between projects.

Options & Flags

OptionDescriptionExample
install Install packages pip install requests
install -r Install from requirements file pip install -r requirements.txt
uninstall Remove a package pip uninstall requests
list List installed packages pip list
freeze Output installed packages in requirements format pip freeze > requirements.txt
show Show package details pip show requests
install --upgrade Upgrade a package pip install --upgrade pip
install --user Install for current user only pip install --user package

Practical Examples

#1 Install package

Installs Flask from PyPI.
$ pip install flask

#2 Install from requirements

Installs all packages listed in requirements.txt.
$ pip install -r requirements.txt

#3 Create requirements file

Exports current packages and versions.
$ pip freeze > requirements.txt

#4 Upgrade pip

Updates pip itself to the latest version.
$ pip install --upgrade pip

#5 Virtual environment workflow

Creates a virtual environment and installs dependencies.
$ python -m venv venv && source venv/bin/activate && pip install -r requirements.txt

#6 Show package info

Shows package version, location, and dependencies.
$ pip show requests

Tips & Best Practices

Always use virtual environments: Never pip install globally. Use python -m venv venv to create isolated environments per project.
pip freeze for reproducibility: pip freeze > requirements.txt captures exact versions. Share this file so others get the same packages.
pip3 vs pip: On systems with both Python 2 and 3, use pip3 to ensure Python 3. Or python3 -m pip for certainty.

Frequently Asked Questions

How do I install a Python package?
pip install package_name. Use within a virtual environment for best practice.
How do I share project dependencies?
pip freeze > requirements.txt exports your packages. Others install with pip install -r requirements.txt.
Why should I use virtual environments?
Virtual environments isolate project dependencies. Without them, different projects can have conflicting package versions.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →