Fundamentals 7 min read

10 Practical pip Commands and Tips for Managing Python Packages

This article introduces ten useful pip techniques—including installation, upgrading, version-specific installs, uninstalling, checking for updates, handling compatibility, using domestic mirrors, downloading without installing, and batch installing from requirements files—to help Python developers efficiently manage their packages.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
10 Practical pip Commands and Tips for Managing Python Packages

For most Python users, pip is a familiar tool, but many are unaware of its full capabilities; this guide presents ten practical pip tips that simplify package management and enhance workflow.

Installation

Since Python 3.4 (and Python 2.7.9), pip is bundled with the official installer, and it is also included in virtual environments created by virtualenv or pyvenv .

If pip is missing, run the following command in a configured Python environment:

<code>py -m ensurepip --upgrade</code>

Alternatively, download get-pip.py from https://bootstrap.pypa.io/get-pip.py and execute python get-pip.py .

How to Use

After installation, typing pip in the command line displays the usage help.

Upgrade pip

To upgrade pip itself, run:

<code>pip install --upgrade pip</code>

or

<code>pip install -U pip</code>

Install a Specific Package Version

Install a package with a particular version using:

<code>pip install package-name</code>

For example, to install matplotlib version 3.4.1:

<code>pip install matplotlib==3.4.1</code>

Uninstall or Update a Package

To uninstall a package:

<code>pip uninstall package_name</code>

To update a package:

<code>pip install --upgrade package_name
# or
pip install -U package_name</code>

Show Package Information

Display detailed information about a package:

<code>pip show -f requests</code>

List Outdated Packages

Find packages that have newer versions available:

<code>pip list -o</code>

Check for Compatibility Issues

Check for dependency conflicts for a specific package or for all installed packages:

<code>pip check package_name
pip check</code>

Install Using Domestic Mirrors

If download speed is slow, specify a Chinese mirror, e.g.:

<code>pip install -i https://pypi.douban.com/simple/ package_name</code>

Common mirrors include Tsinghua, Alibaba Cloud, USTC, HUST, SDUT, and Douban.

Download Without Installing

To download a package to a specific directory without installing:

<code>pip download package_name -d "path/to/dir"</code>

Example:

<code>pip download requests -d "."</code>

Batch Install Packages

Generate a requirements.txt file with currently installed packages:

<code>pip freeze > requirements.txt</code>

Install all packages listed in the file:

<code>pip install -r requirements.txt</code>
command lineInstallationDependencypackage managementvirtualenvpip
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.