If you are learning Python or working on Python projects, pip is one of the most important command-line tools you will use.
pip is Python’s standard package-management tool. It allows developers to install, upgrade, remove, and manage third-party Python packages from the Python Package Index (PyPI) and other package repositories.
For example, if your project needs the requests library, you can install it with:
python -m pip install requests
Instead of manually downloading libraries, copying files, and configuring them yourself, pip handles the package installation process for you.
This Python pip Commands Cheat Sheet covers the most useful pip commands, including package installation, upgrading, uninstalling, searching, listing packages, requirements files, virtual environments, dependency management, troubleshooting, and advanced commands.
What Is pip in Python?
pip is a package installer for Python.
The name is commonly associated with the phrase “Pip Installs Packages.”
Python developers use pip to work with external libraries and packages.
For example:
python -m pip install requests
This command installs the requests package into the current Python environment.
You can use packages to add functionality without writing everything from scratch.
For example:
requests→ HTTP requestsnumpy→ Numerical computingpandas→ Data analysisflask→ Web applicationsdjango→ Web developmentfastapi→ APIspytest→ Testingmatplotlib→ Data visualization
Official pip Documentation
Read the official pip documentation
Python Package Index
PyPI is the main public repository from which many Python packages are installed.
Why Is pip Important?
Python itself provides many built-in modules, but developers often need additional functionality.
For example, Python does not provide every feature required to build a modern web application, data-analysis application, or AI project.
Instead of implementing everything manually, you can install existing packages.
For example:
python -m pip install flask
Now your environment can use Flask.
This makes development:
- Faster
- Easier
- More modular
- More maintainable
- More productive
pip vs Python
It is important to understand that Python and pip are different tools.
Python is the programming language and interpreter.
pip is a package-management tool used to install Python packages.
For example:
python app.py
runs a Python program.
While:
python -m pip install requests
installs a Python package.
How to Check Whether pip Is Installed
Before using pip, check whether it is available.
On Windows:
python -m pip --version
On macOS/Linux:
python3 -m pip --version
You may see output similar to:
pip 25.x from /path/to/site-packages/pip
The exact version will depend on your installed Python environment.
Why Use python -m pip Instead of Just pip?
You will often see two forms:
pip install requests
and:
python -m pip install requests
Both can work, but:
python -m pip
is often safer when multiple Python installations exist.
It explicitly tells Python to run the pip module associated with that Python interpreter.
For example:
python -m pip install flask
means:
Use this Python interpreter’s pip to install Flask.
On macOS/Linux, you may use:
python3 -m pip install flask
This can prevent situations where pip points to a different Python installation.
Basic pip Commands Cheat Sheet
Here are the commands you will use most often.
| Task | Command |
|---|---|
| Check pip version | python -m pip --version |
| Install package | python -m pip install package |
| Install specific version | python -m pip install package==1.2.3 |
| Upgrade package | python -m pip install --upgrade package |
| Uninstall package | python -m pip uninstall package |
| List packages | python -m pip list |
| Show package information | python -m pip show package |
| Check outdated packages | python -m pip list --outdated |
| Freeze dependencies | python -m pip freeze |
| Install from requirements | python -m pip install -r requirements.txt |
| Uninstall from requirements | python -m pip uninstall -r requirements.txt |
| Upgrade pip | python -m pip install --upgrade pip |
1. Check pip Version
The first command you should know is:
python -m pip --version
On some systems:
python3 -m pip --version
Example output:
pip 25.x from /usr/local/lib/python3.x/site-packages/pip
This tells you:
- pip version
- Python version environment
- pip installation location
2. Install a Python Package
The most common pip command is:
python -m pip install requests
This downloads and installs the requests package.
You can replace requests with any package available from your configured package index.
For example:
python -m pip install numpy
or:
python -m pip install pandas
or:
python -m pip install flask
3. Install Multiple Packages
You can install multiple packages in a single command:
python -m pip install requests flask pandas
pip will process each package and install the required dependencies.
This is useful when setting up a new development environment.
4. Install a Specific Package Version
Sometimes your application requires a particular version of a package.
Use:
python -m pip install requests==2.32.3
The == operator specifies an exact version.
For example:
requests==2.32.3
This is useful when your project depends on a specific package release.
5. Install a Minimum Version
You can also specify a minimum version.
python -m pip install "requests>=2.30.0"
This tells pip that the installed version should be at least 2.30.0.
6. Install a Version Range
You can specify a range of acceptable versions.
For example:
python -m pip install "requests>=2.30,<3.0"
This allows versions from 2.30 up to, but not including, 3.0.
Version constraints are commonly used in dependency files.
7. Upgrade a Package
To upgrade an installed package:
python -m pip install --upgrade requests
Short form:
python -m pip install -U requests
The package will be updated to a newer compatible version according to pip’s package-resolution rules and the constraints you provide.
8. Upgrade pip Itself
Keeping pip updated can be useful.
Run:
python -m pip install --upgrade pip
On macOS/Linux:
python3 -m pip install --upgrade pip
After upgrading, check the version:
python -m pip --version
9. Uninstall a Package
To remove a package:
python -m pip uninstall requests
pip will normally ask you to confirm the removal.
You can use:
python -m pip uninstall -y requests
The -y option automatically confirms the uninstall operation.
Use it carefully because it removes the package without asking for confirmation.
10. Uninstall Multiple Packages
You can remove several packages:
python -m pip uninstall requests flask pandas
You can also use a requirements file:
python -m pip uninstall -r requirements.txt
Be careful when using this in an environment containing packages needed by other projects.
This is one reason virtual environments are useful.
11. List Installed Packages
To see packages installed in your current Python environment:
python -m pip list
Example:
Package Version
---------- -------
pip 25.x
requests 2.x
urllib3 2.x
The exact package versions will vary.
This command is particularly useful when troubleshooting dependency problems.
12. Show Package Information
To get detailed information about a package:
python -m pip show requests
The output can include information such as:
- Package name
- Version
- Summary
- Home page
- Author information
- Installation location
- Dependencies
- Required-by
This is useful when you need to determine exactly which version is installed and where it is located.
13. Check Outdated Packages
To see packages that have newer versions available:
python -m pip list --outdated
You may see something similar to:
Package Version Latest
requests 2.x 2.x
The exact values will depend on your environment.
This command is useful for reviewing dependencies before upgrading them.
14. Freeze Installed Packages
One of the most useful pip commands for project management is:
python -m pip freeze
It displays installed packages in a format suitable for a requirements file.
For example:
requests==2.x
urllib3==2.x
The exact output depends on your environment.
15. Create a requirements.txt File
You can save the current environment’s package list into a file:
python -m pip freeze > requirements.txt
Now your project contains:
requirements.txt
The file may contain:
requests==2.x
flask==3.x
This allows another developer or deployment environment to reproduce the project’s Python dependencies.
16. Install Packages from requirements.txt
If a project contains:
requirements.txt
you can install all listed dependencies with:
python -m pip install -r requirements.txt
This is one of the most important commands for Python projects.
For example, if the file contains:
flask
requests
pandas
pip will install those packages and their required dependencies.
17. Install a Package Without Using the Cache
pip may use cached package files to avoid downloading the same content repeatedly.
If you specifically need to disable cache usage:
python -m pip install --no-cache-dir requests
This can sometimes be useful in Docker builds or when troubleshooting cache-related installation problems.
18. Upgrade All Packages
pip does not provide a single universal command that blindly upgrades every installed package safely.
You can first inspect outdated packages:
python -m pip list --outdated
Then upgrade packages individually:
python -m pip install --upgrade requests
For production projects, blindly upgrading everything can introduce compatibility issues.
It is better to test dependency upgrades carefully.
19. Install a Package from a Git Repository
pip can install packages directly from version-control repositories when the package/project supports it.
For example:
python -m pip install git+https://github.com/example/project.git
This approach is often used when:
- A package is not yet released on PyPI
- You need a development version
- You need a specific repository revision
Always make sure you trust the repository before installing code from it.
20. Install a Package from a Local Directory
If you have a Python package stored locally, you can install it using a path.
For example:
python -m pip install .
Run this from the package’s project directory.
You can also specify a path:
python -m pip install /path/to/project
This is common when developing your own Python package.
21. Install a Local Package in Editable Mode
When developing a Python package, editable installation is useful:
python -m pip install -e .
This allows changes in the local source code to be reflected without repeatedly reinstalling the package.
Editable installs are commonly used during package development.
22. Install Optional Dependencies
Some Python packages provide optional features.
pip supports extras when the package defines them.
For example:
python -m pip install "package[extra]"
A project may define extras such as:
package[dev]
package[test]
package[docs]
The exact extras depend on the package.
23. Check Package Dependencies
Use:
python -m pip show requests
The output includes a Requires field when the package declares dependencies.
For deeper dependency inspection, tools outside core pip can also be useful, but always verify that the tool supports your Python environment.
24. Download Packages Without Installing
pip can download packages and their distributions:
python -m pip download requests
This downloads the package files into the current directory instead of installing them.
You can specify a destination:
python -m pip download requests -d packages/
This can be useful for offline installation workflows.
25. Install Packages from a Local Directory
If package files have already been downloaded:
python -m pip install --no-index --find-links=packages/ requests
This tells pip to look in the local packages/ directory rather than searching the normal package index.
This approach can be useful in restricted or offline environments.
26. Check Which pip Is Being Used
On Windows:
where pip
On macOS/Linux:
which pip
However, when multiple Python installations exist, checking:
python -m pip --version
is often more useful because it shows the pip associated with the Python interpreter you invoked.
27. Use pip with a Virtual Environment
A recommended Python workflow is:
python -m venv .venv
Activate the environment.
Windows
.venv\Scripts\activate
macOS/Linux
source .venv/bin/activate
Then install packages:
python -m pip install requests
When you finish:
deactivate
Virtual environments prevent project dependencies from unnecessarily affecting your system-wide Python installation.
28. Install pip if It Is Missing
Modern Python installations commonly include pip, but some environments may not have it available.
First check:
python -m pip --version
If pip is missing, use the installation method recommended by your operating system or Python distribution.
On Linux, for example, a distribution may provide a package such as:
sudo apt install python3-pip
Avoid downloading random scripts from the internet to install pip.
For the latest supported guidance, consult the official pip installation documentation.
Official pip Installation Guide
29. pip Configuration
pip can be configured using configuration files and command-line options.
For example, you can inspect pip’s configuration with:
python -m pip config list
You can also use:
python -m pip config debug
These commands can help identify configuration files and settings affecting pip.
This becomes particularly useful when working with:
- Private package repositories
- Corporate package indexes
- Custom certificates
- Proxy settings
- Custom cache directories
30. Use a Different Package Index
By default, pip commonly uses the Python Package Index.
You can specify another package index using:
python -m pip install package --index-url https://example.com/simple/
This is useful for organizations that maintain private package repositories.
Do not change package indexes unless you understand and trust the source.
31. Use a Proxy with pip
In corporate environments, internet access may require a proxy.
pip supports proxy configuration through its options and configuration mechanisms.
For example:
python -m pip install requests --proxy http://proxy.example.com:8080
The exact proxy configuration depends on your network environment.
32. Install Packages for a Specific Python Version
If multiple Python versions are installed, explicitly invoke the desired interpreter.
For example:
python3.12 -m pip install requests
On Windows, the Python launcher can be useful:
py -3.12 -m pip install requests
This ensures the package is installed into the intended Python environment.
33. pip and Virtual Environment Best Practice
A good project workflow looks like this:
mkdir my-project
cd my-project
python -m venv .venv
Activate the environment.
Then:
python -m pip install --upgrade pip
Install dependencies:
python -m pip install requests
Save dependencies:
python -m pip freeze > requirements.txt
This gives you a reproducible starting point for your project.
34. Requirements Files
A requirements.txt file is commonly used to record Python dependencies.
Example:
requests==2.x
flask==3.x
Another developer can install the dependencies with:
python -m pip install -r requirements.txt
Requirements files can also contain constraints and references to other dependency sources.
For larger applications, modern Python projects may use tools and project metadata based on pyproject.toml rather than relying only on requirements.txt.
35. pip vs requirements.txt
These two concepts are related but different.
pip
pip is the tool that installs and manages packages.
requirements.txt
requirements.txt is a file that records dependencies that can be installed by pip.
For example:
python -m pip install -r requirements.txt
Here:
pipperforms the installation.requirements.txtprovides the dependency list.
36. pip vs PyPI
Another common beginner confusion is the difference between pip and PyPI.
PyPI
PyPI is a package repository.
pip
pip is a package installer.
A simple way to remember it:
PyPI stores packages.
pip installs packages.
For example:
python -m pip install requests
pip can retrieve the package from a configured package index such as PyPI.
37. Useful pip Options
pip commands can use different options depending on what you need.
Some commonly encountered options include:
--upgrade
-U
--user
--no-cache-dir
-r
--dry-run
--verbose
--quiet
For example:
python -m pip install --upgrade requests
or:
python -m pip install --no-cache-dir requests
Always check the documentation for the specific pip command you are using.
38. Troubleshooting pip Installation Errors
“No matching distribution found”
You may see an error indicating that pip cannot find a compatible package version.
Possible causes include:
- Package does not support your Python version
- Package does not support your operating system
- Incorrect package name
- Package version is unavailable
- Network or package-index problems
First verify the package name and Python version.
Check:
python --version
Then check the package’s official documentation.
39. “Could not find a version that satisfies the requirement”
This error often means that no available package distribution matches your environment or requested version.
For example, a package may not support your current Python version.
Check:
python --version
Then check the package’s supported Python versions on PyPI or its official documentation.
40. Permission Errors
Avoid installing packages globally with elevated privileges unless you understand why it is necessary.
For development projects, a virtual environment is usually the better solution:
python -m venv .venv
Activate it and install packages there.
This avoids many permission and dependency conflicts.
41. SSL or Network Errors
pip may fail because of:
- Internet connectivity
- Corporate firewall
- Proxy configuration
- Certificate configuration
- Private package repository settings
If this happens, first verify that your network connection works and check your organization’s package-management requirements.
Avoid disabling SSL verification as a quick fix unless you fully understand the security implications.
42. Dependency Conflicts
Suppose one package requires:
packageA >= 2.0
while another package requires:
packageA < 2.0
The environment may have incompatible requirements.
When this happens:
- Read the error message.
- Check package versions.
- Review project documentation.
- Use a clean virtual environment.
- Pin compatible dependency versions when appropriate.
A clean environment often makes dependency problems easier to diagnose.
43. Useful pip Commands for Daily Development
If you only remember a few commands, remember these:
# Check pip
python -m pip --version
# Install package
python -m pip install requests
# Upgrade package
python -m pip install --upgrade requests
# Remove package
python -m pip uninstall requests
# List packages
python -m pip list
# Show package information
python -m pip show requests
# Check outdated packages
python -m pip list --outdated
# Export dependencies
python -m pip freeze > requirements.txt
# Install project dependencies
python -m pip install -r requirements.txt
# Upgrade pip
python -m pip install --upgrade pip
Complete Python pip Cheat Sheet
| Command | Purpose |
|---|---|
python -m pip --version | Check pip version |
python -m pip install package | Install package |
python -m pip install package==1.0.0 | Install exact version |
python -m pip install "package>=1.0" | Install minimum version |
python -m pip install --upgrade package | Upgrade package |
python -m pip uninstall package | Remove package |
python -m pip list | List installed packages |
python -m pip show package | Show package information |
python -m pip list --outdated | Find outdated packages |
python -m pip freeze | Display installed packages in requirements format |
python -m pip freeze > requirements.txt | Save dependencies |
python -m pip install -r requirements.txt | Install dependencies |
python -m pip uninstall -r requirements.txt | Uninstall listed dependencies |
python -m pip download package | Download package |
python -m pip install . | Install local package |
python -m pip install -e . | Install local package in editable mode |
python -m pip config list | Display pip configuration |
python -m pip config debug | Debug pip configuration |
python -m pip cache info | Show cache information |
python -m pip cache purge | Remove pip cache |
python -m pip check | Check installed packages for dependency compatibility |
Best Practices When Using pip
Using pip correctly is important for maintaining stable Python projects.
Use Virtual Environments
Create a separate environment for each project.
python -m venv .venv
Prefer python -m pip
Instead of:
pip install package
prefer:
python -m pip install package
when you need to make sure pip belongs to a particular Python interpreter.
Avoid Unnecessary Global Installation
Installing packages globally can cause dependency conflicts.
Use a virtual environment instead.
Keep Dependencies Documented
Use:
python -m pip freeze > requirements.txt
when appropriate.
For modern projects, also understand pyproject.toml and the packaging ecosystem rather than assuming every project should use only requirements.txt.
Test Before Upgrading
Don’t blindly upgrade every package in a production application.
Test upgrades before deploying them.
Use Trusted Package Sources
Install packages from trusted repositories and verify package names carefully.
Frequently Asked Questions
What is pip used for in Python?
pip is primarily used to install and manage Python packages and their dependencies.
Is pip included with Python?
Many standard Python installations include pip, but availability can vary depending on the operating system and distribution.
You can check with:
python -m pip --version
What is the difference between pip and PyPI?
PyPI is a package repository, while pip is a package-management tool that can install packages from configured indexes.
Should I use pip or python -m pip?
python -m pip is often preferable because it makes it clear which Python interpreter’s pip is being used.
How do I install a specific version?
Use:
python -m pip install package==1.2.3
Replace the package name and version with the values required by your project.
How do I update a package?
Use:
python -m pip install --upgrade package
How do I uninstall a package?
Use:
python -m pip uninstall package
How do I see installed packages?
Run:
python -m pip list
How do I create a requirements file?
Run:
python -m pip freeze > requirements.txt
How do I install dependencies from a requirements file?
Run:
python -m pip install -r requirements.txt
Final Thoughts
pip is an essential tool for almost every Python developer.
Once you understand a few core commands, managing Python packages becomes much easier.
The most important commands to remember are:
python -m pip install package
python -m pip install --upgrade package
python -m pip uninstall package
python -m pip list
python -m pip show package
python -m pip freeze > requirements.txt
python -m pip install -r requirements.txt
For professional Python development, combine pip with virtual environments, dependency files, version control, and proper project configuration.
If you are a beginner, don’t try to memorize every command at once. Start with installing packages, checking installed packages, upgrading and removing packages, and managing dependencies with a virtual environment.
Once you become comfortable with these commands, pip will become a normal part of your everyday Python development workflow.




