[Avg. reading time: 5 minutes]
Introduction
Before diving into Data or ML frameworks, it's important to have a clean and reproducible development setup. A good environment makes you:
- Faster: less time fighting dependencies.
- Consistent: same results across laptops, servers, and teammates.
- Confident: tools catch errors before they become bugs.
A consistent developer experience saves hours of debugging. You spend more time solving problems, less time fixing environments.
Python Virtual Environment
- A virtual environment is like a sandbox for Python.
- It isolates your project’s dependencies from the global Python installation.
- Easy to manage different versions of library.
- Must depend on requirements.txt, it has to be managed manually.
Without it, installing one package for one project may break another project.
Open the CMD prompt (Windows)
Open the Terminal (Mac)
# Step 0: Create a project folder under your Home folder.
mkdir project
cd project
# Step 1: Create a virtual environment
python -m venv myenv
# Step 2: Activate it
# On Mac/Linux:
source myenv/bin/activate
# On Windows:
myenv\Scripts\activate.bat
# Step 3: Install packages (they go inside `myenv`, not global)
pip install faker
# Step 4: Open Python
python
# Step 5: Verify
import sys
sys.prefix
sys.base_prefix
# Step 6: Run this sample
from faker import Faker
fake = Faker()
fake.name()
# Step 6: Close Python (Control + Z)
# Step 7: Deactivate the venv when done
deactivate
As a next step, you can either use Poetry or UV as your package manager.