Complete AI Development Environment Setup
Set up a professional AI engineering workspace from scratch — Python, VS Code, Jupyter, virtual environments, and your first Groq API call.
Complete AI Development Environment Setup
A reproducible, isolated development environment is the foundation of every serious AI project. If you skip this step and rely on system Python or ad-hoc package installs, you will eventually hit a dependency conflict that costs you hours. This guide walks you through a professional setup from scratch — the same way engineers at production AI teams work.
Why Environment Setup Matters
Two properties matter most in AI development: reproducibility and isolation.
Reproducibility means another engineer (or your future self) can clone your repo, run one command, and get an identical working environment. Without it, "works on my machine" becomes a recurring nightmare.
Isolation means your project's dependencies do not conflict with each other or with system tools. AI projects routinely require pinned versions of PyTorch, NumPy, and transformers libraries that are mutually incompatible across projects. Isolated virtual environments solve this completely.
Python Installation with pyenv
Never use your operating system's Python. System Python is managed by the OS, can be updated or removed by system upgrades, and is used by OS-level tools that can break if you install packages globally. Use pyenv instead — it lets you install and switch between any Python version per-project.
macOS
Linux (Ubuntu/Debian)
Windows
On Windows, use pyenv-win:
Note: On Windows, prefer WSL 2 (Windows Subsystem for Linux) for serious AI development. Most ML tooling is Linux-first, and you avoid many compatibility headaches by working inside Ubuntu on WSL 2.
Virtual Environments: venv vs conda vs uv
You have three mainstream options:
| Tool | Speed | Lockfile | Best for |
|------|-------|----------|----------|
| venv | Slow | No | Simple scripts |
| conda | Medium | Yes | Data science (handles non-Python deps) |
| uv | Very fast | Yes (uv.lock) | Modern Python projects |
Recommendation: use uv. It is a drop-in replacement for pip and venv written in Rust. It resolves and installs packages 10-100x faster than pip, produces a lockfile, and handles Python version management natively.
Install uv
Start a New Project with uv
The uv.lock file that uv generates pins every transitive dependency. Commit it to git — it is your reproducibility guarantee.
VS Code Setup
VS Code is the standard IDE for AI/ML work. Install it from code.visualstudio.com.
Essential Extensions
Install these extensions from the VS Code Extensions panel (Ctrl+Shift+X / Cmd+Shift+X):
| Extension | Publisher | Purpose | |-----------|-----------|---------| | Python | Microsoft | Language support, debugger | | Pylance | Microsoft | Fast type checking, IntelliSense | | Jupyter | Microsoft | .ipynb support inside VS Code | | GitLens | GitKraken | Git blame, history, diffs | | Ruff | Astral Software | Fast linter + formatter |
Install them via the command line:
VS Code settings.json for Python
Open your project in VS Code, then create .vscode/settings.json:
Note: The
python.defaultInterpreterPathpoints to the.venvinside your project. VS Code will automatically use this interpreter for linting, formatting, and running code — no manual selection needed after first open.
JupyterLab Setup
JupyterLab is the browser-based notebook interface. Install it in your project venv:
Register Your Project Kernel
By default, notebooks run in the base Python environment. Register your project's venv as a named kernel so notebooks always use your project's packages:
Now, when you open a notebook in JupyterLab, select "Python (my-ai-project)" from the kernel menu.
Useful JupyterLab Extensions
VS Code Jupyter Integration
You do not need to leave VS Code to use notebooks. Open any .ipynb file in VS Code — the Jupyter extension provides a full notebook UI. Select your registered kernel from the kernel picker in the top-right of the notebook editor.
This gives you the best of both worlds: notebook interactivity with VS Code's editor features (IntelliSense, GitLens, integrated terminal).
Project Structure Best Practices
A well-organised AI project looks like this:
Environment Variables and the .env Pattern
Never hardcode API keys in source code. Use environment variables loaded from a .env file during development.
Create .env in your project root:
Create .env.example with placeholder values (safe to commit):
Load the variables in Python:
Git Setup for AI Projects
Initialize git and add a proper .gitignore:
Create .gitignore:
Note: Use Git LFS (
git lfs install) if you must version-control model files or large datasets. Never commit binary model files to regular git — they bloat the repository permanently.
Your First Groq API Call
Get a free API key from console.groq.com. It takes under two minutes.
Install the Groq client:
Create test_groq.py:
Run it:
You should see a clean explanation and a token count. If you get an AuthenticationError, double-check that your .env file is in the project root and GROQ_API_KEY is set correctly.
Summary
- Use pyenv to install and manage Python versions — never use system Python.
- Use uv for virtual environments and package management; it is 10-100x faster than pip and produces a lockfile for reproducibility.
- Install Python, Pylance, Jupyter, GitLens, and Ruff extensions in VS Code and configure
settings.jsonto format on save. - Register your project's venv as a named Jupyter kernel so notebooks always use your project's packages.
- Store secrets in a
.envfile loaded with python-dotenv, add.envto.gitignore, and commit.env.exampleas a template.