pip Commands Cheatsheet
Python package installation, requirements.txt, and venv basics
Your data never leaves the browser — all processing is done locally 0 server requests
Basic Installation & Removal
-
pip install 패키지명Install a package
-
pip install 패키지명==1.2.3Install a specific version of a package
-
pip install "패키지명>=2.0,<3.0"Install a package within a version range
-
pip install 패키지명 --upgradeUpgrade a package to the latest version
-
pip install 패키지명 --preInstall including beta and RC pre-releases
-
pip uninstall 패키지명Uninstall a package
-
pip uninstall -y 패키지명Uninstall without a confirmation prompt
Using requirements Files
-
pip install -r requirements.txtInstall all packages listed in requirements.txt
-
pip freeze > requirements.txtSave the current environment's package list to a file
-
pip freeze | grep -v "^-e" > requirements.txtSave package list excluding editable (-e) packages
Package Listing, Search & Info
-
pip listShow installed packages and their versions
-
pip list --outdatedShow packages that have newer versions available
-
pip show 패키지명Show a package's version, location, and dependencies
-
pip search 패키지명Search PyPI for a package (deprecated; use pypi.org directly)
Managing pip Itself
-
pip --versionCheck the pip version
-
pip install --upgrade pipUpgrade pip itself to the latest version
-
python -m pip install --upgrade pipUpgrade pip using the recommended method
Cache, Download & Source Installation
-
pip install --no-cache-dir 패키지명Install a package without using the cache
-
pip cache purgeDelete all local pip cache files
-
pip download 패키지명 -d ./wheelsDownload a package as a .whl file without installing (for offline use)
-
pip install 패키지.whlInstall directly from a local .whl file
-
pip install -e .Install the current directory package in editable (development) mode
-
pip install git+https://github.com/user/repo.gitInstall directly from a GitHub repository
Using with Virtual Environments (venv)
How to use pip with the standard Python venv (not conda)
-
python -m venv .venvCreate a .venv virtual environment in the current directory
-
source .venv/bin/activateActivate the virtual environment (Linux/macOS)
-
.venv\Scripts\activateActivate the virtual environment (Windows CMD)
-
deactivateDeactivate the virtual environment
pip: Always Use a Virtual Environment
pip is Python's official package manager. Installing into the system Python directly can break other projects. The recommended workflow: python -m venv .venv → source .venv/bin/activate → pip install. Keep a requirements.txt at the project root for reproducible installs.
For production environments requiring strict version pinning, consider pip-compile from pip-tools. It resolves the full dependency tree and writes a locked requirements.txt, similar to package-lock.json in Node.js.
Run pip audit regularly to scan for known security vulnerabilities in your installed packages.
FAQ
- What is the difference between pip install and pip install --upgrade?
- pip install <package> does nothing if the package is already installed. Add --upgrade (-U) to fetch and install the latest version. Use pip list --outdated first to see which packages can be updated.
- What is the difference between pip list and pip freeze?
- pip list shows packages in a human-readable table. pip freeze outputs them in package==version format ready for requirements.txt. Use pip freeze > requirements.txt to capture your environment for sharing.
- How do I install a package only for my user, not system-wide?
- Use pip install --user <package> to install in your home directory without touching the system Python. However, using a virtual environment (venv or conda) is the recommended approach — it is cleaner and avoids polluting global state.