Fundamentals 6 min read

10 Practical Tips for Using pip in Python

This guide introduces ten useful pip techniques—including installation, basic commands, upgrading, version-specific installs, uninstalling, inspecting package details, checking for conflicts, using domestic mirrors, downloading without installing, and batch installing from requirements files—to help Python developers manage packages more efficiently.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
10 Practical Tips for Using pip in Python

Since Python 3.4 (and 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, you can install it with py -m ensurepip --upgrade or by running the get-pip.py script downloaded from the official site.

After installation, typing pip in the command line displays the usage help. To upgrade pip itself, run pip install --upgrade pip or the shorter pip install -U pip .

To install a specific package, use pip install package-name . For a particular version, add the version specifier, e.g., pip install matplotlib==3.4.1 . Uninstall a package with pip uninstall package_name , and upgrade an existing package with pip install --upgrade package_name (or pip install -U package_name ).

Package information can be displayed using pip show -f requests , which lists metadata such as name, version, summary, homepage, author, license, location, dependencies, and installed files.

To see which installed packages have newer releases, run pip list -o . The command outputs a table of outdated packages, their current and latest versions, and the distribution type.

Compatibility issues can be checked with pip check (or pip check package_name for a specific package), which reports version conflicts among installed packages.

If download speed is a concern, you can specify a domestic mirror, for example: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple package_name . Common Chinese mirrors include Tsinghua, Alibaba Cloud, USTC, HUST, Shandong University, and Douban.

To download a package without installing it, use pip download package_name -d "target_path" ; for example, pip download requests -d "." saves the package and its dependencies to the current directory.

For batch operations, generate a requirements.txt file with pip freeze > requirements.txt . Then install all listed packages in one step with pip install -r requirements.txt .

Pythoncommand lineUpgradetutorialInstallationPackage Managementpip
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.