PIP
Overview of the Standard Python Package Manager, PIP.
Introduction
The standard Python package manager is pip. It is ideal for quickly starting Python projects, like simple scripts or small projects with few dependencies. While capable of handling larger projects, tools like poetry are ideal for larger projects with complex dependencies.
The following notes assume:
Python 3
MacOS
An alias in
bashprofile to mappythontopython3.
Setup
The following is a step-by-step process for setting up a virtual environment in my-project and installing dependencies in it with pip.
cdinto your project directory.
cd my-projectCreate the virtual environment named
env.
python -m venv envActivate the virtual environment.
source env/bin/activateInstall dependencies.
pip install <PACKAGE_NAME>Commands
The following is a list of common commands used when managing a project with pip.
Activate Virtual Environment
source env/bin/activateDeactivate Virtual Environment
deactivateUninstall a Package
pip uinstall <PACKAGE_NAME>List Installed Packages
pip freezeCreate a requirements.txt File
pip freeze > requirements.txtInstall Packages from a requirements.txt File
pip install -r requirements.txtPitfalls & Solutions
The following are common pitfalls when working with pip and their solutions.
Last updated
Was this helpful?