Namraj Pudasaini
Jun 22, 2026
Python is one of the most widely used languages in the world, but a clean development workflow matters just as much as the code itself. This guide covers the essentials — virtual environments, dependency management, and handy tricks that save time day to day.
venvVirtual environments keep each project's dependencies isolated from one another and from your system Python. Every project should have its own — it prevents version conflicts and makes your setup reproducible on any machine.
mkdir projectA && cd projectA
python3 -m venv env
source env/bin/activate # Linux / macOS
env\Scripts\activate.bat # Windows CMD
env\Scripts\Activate.ps1 # Windows PowerShell
To exit the environment, run deactivate.
The python3 -m venv env command creates an env/ folder containing an isolated Python binary, pip, and a lib/ directory for installed packages. Always add env/ to your .gitignore — it should never be committed to version control.
pip is Python's package installer. The key workflow is to install what you need, then freeze those dependencies into a requirements.txt file so anyone else can reproduce your exact environment with a single command.
pip install flask # install a package
pip list # see installed packages
pip freeze > requirements.txt # save exact versions
pip install -r requirements.txt # restore from file
To cleanly reinstall all dependencies when something breaks:
pip uninstall flask
pip install -r requirements.txt
This is often the fastest way to resolve mysterious dependency conflicts.
virtualenvwrapper for ConvenienceIf you manage many projects, virtualenvwrapper gives you short commands to create, switch, list, and delete environments from anywhere on your system:
pip3 install virtualenvwrapper
mkvirtualenv my-project # create
workon my-project # activate
lsvirtualenv # list all environments
rmvirtualenv my-project # delete
Run echo $VIRTUAL_ENV at any time to confirm which environment is currently active — it prints the full path or nothing if none is active.
Python ships with a built-in HTTP server for serving static files locally — great for previewing HTML or sharing a folder over a network:
python -m http.server 8000
This serves the current directory at http://localhost:8000.
When working in the Python REPL, the screen fills up quickly. Use os.system() to call the terminal's clear command:
import os
clear = lambda: os.system('cls' if os.name == 'nt' else 'clear')
clear()
os.name == 'nt' evaluates to True on Windows and False on Linux or macOS, so the same function works everywhere.
When running Python inside WSL (Windows Subsystem for Linux), your Windows files are accessible under /mnt/c/:
cd /mnt/c/Users/yourname/dev/my-project
python3 -m venv env
source env/bin/activate
If you run into issues with Node-based tools (like Vite) inside WSL, a common fix is to delete node_modules and reinstall from within the Linux environment, or set CHOKIDAR_USEPOLLING=true to work around file-watcher mismatches between Windows and Linux.
A solid Python workflow comes down to three habits: always use a virtual environment, keep your requirements.txt up to date, and know your tools. The commands above cover the majority of what you need for day-to-day Python development.