UnixDroid

Lesson 2 of 12 · 6 min

Set up Python on Kali Linux (venv and pip)

Kali ships with Python 3. Here's how to set up a clean virtual environment and install the libraries this path uses.

Kali Linux ships with Python 3 already installed, so you can start writing security scripts in minutes. The trick is doing it cleanly — keeping each project's libraries separate so one tool never breaks another.

Check what you already have

Confirm Python is there:

python3 --version
pip3 --version

If python3 prints something like 3.11.x, you're ready. Python 2 is dead — always use python3.

Why you want a virtual environment

Install enough tools and two of them will eventually demand different versions of the same library. A virtual environment (venv) gives each project its own private box of packages, so they never collide.

mkdir ~/pytools && cd ~/pytools
python3 -m venv .venv
source .venv/bin/activate

Your prompt now starts with (.venv). Anything you pip install from here lives only in this project.

Installing the libraries you'll use

pip install requests scapy
LibraryUsed for
requestsTalking to websites and APIs
scapyCrafting and sniffing packets
hashlibHashing (built in)
socketLow-level network connections (built in)

Tip: Type deactivate to leave the venv; next time, cd back and run source .venv/bin/activate again. On Kali you'll hit an "externally managed environment" error if you pip install outside a venv — that warning is exactly why the venv exists.

A tidy project layout

Keep scripts, wordlists and output in separate folders from day one:

pytools/
  .venv/
  scanners/
  wordlists/
  output/

Future-you, debugging a scan at 2am, will thank present-you for the tidy folders.

Try it yourself
  1. Create a venv in a new folder and activate it.
  2. Run pip install requests, then pip list to see it appear.
  3. Run deactivate and watch your prompt lose the (.venv) tag.
No Linux machine? Practise in the free online terminal

Quick check

What Python feature keeps each project's libraries isolated so they don't conflict?

Need a hint?

Short for virtual environment.

Finished this lesson?

Done lessons keep your daily streak going 🔥

0 day streak

0 lessons done

best 0 days

Log in to keep your streak on every device →