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
| Library | Used for |
|---|---|
requests | Talking to websites and APIs |
scapy | Crafting and sniffing packets |
hashlib | Hashing (built in) |
socket | Low-level network connections (built in) |
Tip: Type
deactivateto leave the venv; next time,cdback and runsource .venv/bin/activateagain. On Kali you'll hit an "externally managed environment" error if youpip installoutside 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.