Python PIP
Python includes a standard library. When a program needs another package, use pip to install it into the Python environment that runs the program.
Check the interpreter
A notebook kernel may use a different interpreter from your terminal. Inspect its executable before installing packages.
import sys
print(sys.executable)
print(sys.version)Output
/opt/anaconda3/bin/python
3.13.5 | packaged by Anaconda, Inc. | (main, Jun 12 2025, 11:23:37) [Clang 14.0.6 ]
Install and inspect a package
Run these commands in a terminal with your chosen environment active:
python -m pip --version
python -m pip install requests
python -m pip show requests
python -m pip listpython -m pip uses pip belonging to that interpreter. After installation, a Python program imports the package with import requests. The package name used for installation and the import name are not always identical.
Record dependencies
python -m pip freeze > requirements.txt
python -m pip install -r requirements.txtThe first command records installed versions. The second installs the recorded requirements in another environment. Keep the requirements with the project. Recreate the environment rather than copying its directory between computers.
Reference: pip user guide, checked 20 October 2026.