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: py -m ensurepip --upgrade 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: pip install --upgrade pip or

pip install -U pip

Install a Specific Package Version

Install a package with a particular version using: pip install package-name For example, to install matplotlib version 3.4.1:

pip install matplotlib==3.4.1

Uninstall or Update a Package

To uninstall a package: pip uninstall package_name To update a package:

pip install --upgrade package_name
# or
pip install -U package_name

Show Package Information

Display detailed information about a package:

pip show -f requests

List Outdated Packages

Find packages that have newer versions available:

pip list -o

Check for Compatibility Issues

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

pip check package_name
pip check

Install Using Domestic Mirrors

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

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

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

Download Without Installing

To download a package to a specific directory without installing: pip download package_name -d "path/to/dir" Example:

pip download requests -d "."

Batch Install Packages

Generate a requirements.txt file with currently installed packages: pip freeze > requirements.txt Install all packages listed in the file:

pip install -r requirements.txt
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Pythoncommand-lineInstallationdependencypippackage-management
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

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.