Configuring VS Code for Jupyter Development with the AI-For-Beginners Curriculum
You can configure VS Code for Jupyter development with the Microsoft AI-For-Beginners curriculum by creating the Conda environment from .devcontainer/environment.yml, activating it, and opening the repository in VS Code, where the Python extension automatically detects the kernel and provides full notebook support.
The microsoft/AI-For-Beginners repository is a comprehensive educational curriculum that combines executable Jupyter notebooks, containerized development environments, and interactive quizzes. Configuring VS Code for Jupyter development with this curriculum ensures you have IntelliSense, variable exploration, and seamless cell execution while working through the 24 lessons covering PyTorch and TensorFlow implementations. The repository structures its content in the lessons/ directory, with setup instructions documented in lessons/0-course-setup/how-to-run.md and dependencies locked in .devcontainer/environment.yml.
Setting Up the Conda Environment
Before opening VS Code, you must create the isolated Python environment that contains all required libraries. The repository provides a complete Conda environment definition in .devcontainer/environment.yml that pins versions for NumPy, Matplotlib, OpenCV, PyTorch, and TensorFlow.
Run the following commands from the repository root:
# Clone the curriculum
git clone https://github.com/microsoft/AI-For-Beginners.git
cd AI-For-Beginners
# Create and activate the environment
conda env create -f .devcontainer/environment.yml
conda activate ai4beg
The environment name ai4beg is defined in the YAML file. Once activated, this environment provides the exact Python interpreter that VS Code will use for its Jupyter kernel.
Configuring VS Code Workspace Settings
After activating the environment, launch VS Code from the terminal so it inherits the correct environment variables:
code .
The Python extension for VS Code automatically detects the Conda environment and offers to select it as the default interpreter. For explicit control over which Python binary VS Code uses for Jupyter execution, create a workspace settings file at .vscode/settings.json:
{
"python.pythonPath": "/opt/conda/envs/ai4beg/bin/python",
"jupyter.notebookFileRoot": "${workspaceFolder}"
}
This configuration ensures that every notebook you open in lessons/ executes against the ai4beg environment rather than your global Python installation.
Working with Jupyter Notebooks
The curriculum stores executable content in the lessons/ directory, with each lesson containing a README and one or more *.ipynb files. For example, the Perceptron lesson lives at lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb.
When you open any notebook in VS Code:
- Cell execution runs against the selected
ai4begkernel - Variable explorer and data viewer appear in the side panel
- IntelliSense provides autocomplete for PyTorch and TensorFlow APIs
You can also execute notebooks headlessly from the terminal for validation:
jupyter nbconvert --to notebook --execute lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb --output Perceptron-out.ipynb
Container-Based Development
If you prefer an isolated Docker environment over a local Conda installation, VS Code supports the hidden .devcontainer folder included in the repository. When VS Code detects this folder, it prompts you to "Reopen in Container," which automatically:
- Builds a Docker image using the definition in
.devcontainer/ - Installs the
environment.ymldependencies inside the container - Mounts the
lessons/directory for live editing
This workflow eliminates "works on my machine" issues by ensuring the Jupyter kernel runs inside a container with locked dependency versions.
Cloud Alternatives
For users who cannot install Docker or Conda locally, the curriculum supports GitHub Codespaces and Binder. Both platforms read the .devcontainer/environment.yml file and spin up a pre-configured VS Code instance in the browser, allowing you to execute every notebook without local configuration.
Summary
- The AI-For-Beginners curriculum requires the Conda environment defined in
.devcontainer/environment.ymlto ensure reproducible Jupyter execution. - Activate the
ai4begenvironment before launching VS Code withcode .so the Python extension auto-detects the correct interpreter. - Store explicit paths in
.vscode/settings.jsonto force VS Code to use the Conda environment for all notebook kernels. - The
lessons/directory contains 24 lesson folders with executable notebooks compatible with both PyTorch and TensorFlow. - Optional container workflows via
.devcontainer/provide fully isolated development environments without local dependency management.
Frequently Asked Questions
How do I switch between PyTorch and TensorFlow kernels in the notebooks?
The notebooks in the lessons/ directory are framework-agnostic by design. Each notebook imports either PyTorch or TensorFlow based on the code cells you execute. Since both libraries are installed in the ai4beg environment defined in .devcontainer/environment.yml, you simply run the cells corresponding to your preferred framework without switching kernels.
Can I use a different Python environment instead of Conda?
While the repository officially supports Conda via .devcontainer/environment.yml, you can manually install the dependencies listed in that file into a virtualenv or pipenv. However, you must update .vscode/settings.json to point python.pythonPath to your alternative environment’s Python binary to ensure VS Code launches the Jupyter kernel from that location.
What should I do if VS Code does not detect the ai4beg environment?
Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and run "Python: Select Interpreter." If ai4beg does not appear, verify you activated the environment in your terminal before launching VS Code, or manually browse to the Python executable path (e.g., ~/anaconda3/envs/ai4beg/bin/python on Linux/Mac or %USERPROFILE%\anaconda3\envs\ai4beg\python.exe on Windows).
Is internet access required after the initial setup?
Yes, many notebooks download datasets or pre-trained models on first execution. If you are using the container workflow, ensure Docker has internet access during the build phase so that .devcontainer/environment.yml can fetch packages from Conda and PyPI repositories.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →