pip: Python Package Installer

pip is the standard tool for installing Python packages from PyPI. Before installing anything, you should almost always be working inside a virtual environment.

Virtual environments

A virtual environment keeps Python dependencies isolated from the rest of the system. This prevents installing the dependencies of some tool from breaking anything else.

To create one:

python3 -m venv .venv

This creates a .venv directory in your current working directory. This is typically done at the root of a Python project directory, for example, when you're working on a cloned repo like impacket, you'd make the .venv folder there.

Activate the environment:

source .venv/bin/activate

Once activated, your shell prompt will show (.venv) — you're now working inside the isolated environment.

Deactivate when you're done:

deactivate

Installing packages with pip

When inside a virtual environment, using just pip is safe — it's bound to that environment:

pip install requests

However, for clarity and robustness (especially outside of venvs or in scripts), the preferred form is:

python3 -m pip install requests

Some useful packages:

# HTTP library
python3 -m pip install requests

# CTF and exploit dev library
python3 -m pip install pwntools

# Improved Python shell
python3 -m pip install ipython        

# Lightweight web framework
python3 -m pip install flask

Checking installed packages

python3 -m pip list

Requirements files

You can capture the current environment's packages to a file:

python3 -m pip freeze > requirements.txt

Later, or on another system, you can recreate the environment:

python3 -m pip install -r requirements.txt

This is the standard way to share or restore a Python project's dependencies.