How to Set Up the AI for Beginners Conda Environment: A Complete Guide

To set up the AI for Beginners conda environment, clone the repository and run conda env create --name ai4beg --file environment.yml to install all required dependencies including TensorFlow, PyTorch, and Jupyter.

The microsoft/AI-For-Beginners curriculum provides a comprehensive introduction to artificial intelligence through hands-on Jupyter notebooks. To ensure reproducible execution across different machines, the project maintains a locked dependency specification in environment.yml. Setting up the AI for Beginners conda environment correctly prevents version conflicts and provides immediate access to all necessary machine learning libraries.

Prerequisites: Install Miniconda

Before creating the environment, you need the conda package manager installed on your system. Miniconda provides a minimal distribution containing only the essential components.

Download the appropriate installer for your operating system from the official Miniconda distribution page. Run the installer and follow the prompts to add conda to your system PATH.

Step-by-Step Setup Process

Follow these sequential steps to configure your local development environment according to the official curriculum guidelines in lessons/0-course-setup/how-to-run.md.

1. Clone the Repository

Obtain the full curriculum source code including all notebooks and configuration files:

git clone https://github.com/microsoft/AI-For-Beginners.git
cd AI-For-Beginners

2. Create the Conda Environment

The repository includes environment.yml at the root level, which pins exact versions of ipykernel, jupyter, numpy, tensorflow, pytorch, opencv, and additional scientific computing packages. Create the isolated environment using this specification:

conda env create --name ai4beg --file environment.yml

This command reads the dependency graph from environment.yml and resolves compatible versions for all listed packages, ensuring that notebook code executes without import errors or API mismatches.

3. Activate the Environment

Switch your shell context to use the newly created environment:

conda activate ai4beg

Your prompt should now display (ai4beg), indicating that subsequent Python commands will use the isolated interpreter and package set defined in the YAML file.

4. Launch Jupyter

Start the notebook server to access the lesson materials:

jupyter notebook

Alternatively, use JupyterLab for an enhanced interface:

jupyter lab

The server will open in your default web browser, displaying the directory structure of the AI-For-Beginners repository where you can navigate to specific lesson notebooks.

Understanding the Environment Configuration

The environment.yml file in the repository root serves as the single source of truth for the curriculum's Python stack. As documented in the source code, this file specifies core dependencies including deep learning frameworks (tensorflow, pytorch), computer vision libraries (opencv), and interactive computing tools (jupyter, ipykernel).

When you run conda env create, the solver processes these specifications to build a consistent environment that matches the testing conditions used by the curriculum maintainers. This eliminates "works on my machine" issues when executing neural network training cells or OpenCV image processing examples.

VS Code Integration

For developers preferring an integrated development experience, the setup supports Visual Studio Code with the Python extension.

After activating the ai4beg environment in your terminal, open the repository folder in VS Code:

code .

The Python extension automatically detects the ai4beg kernel and suggests installing any missing extensions required for Jupyter notebook support. This allows you to run notebook cells directly within the editor while maintaining access to variable explorers and debugging tools.

Summary

  • Use the provided YAML: The environment.yml file in the microsoft/AI-For-Beginners repository defines the exact package versions required for the curriculum.
  • Three-step workflow: Install Miniconda, create the environment with conda env create --name ai4beg --file environment.yml, and activate it with conda activate ai4beg.
  • Launch options: Start Jupyter via command line or use VS Code for an integrated notebook editing experience.
  • Dependency coverage: The environment includes TensorFlow, PyTorch, OpenCV, NumPy, and Jupyter dependencies pre-configured.

Frequently Asked Questions

Can I use pip instead of conda to install the dependencies?

While conda is the officially supported method documented in the README.md and setup guides, you can manually install equivalent packages using pip if conda is unavailable. However, the environment.yml uses conda-specific channels and dependency resolution that better handle binary packages like PyTorch and OpenCV, making conda the recommended approach for this curriculum.

How do I update the environment if the repository adds new dependencies?

If the upstream repository updates environment.yml with new packages, navigate to your local clone and run conda env update --name ai4beg --file environment.yml. This command adds or upgrades packages while preserving your existing environment structure, ensuring compatibility with the latest lesson notebooks.

What should I do if the environment creation fails on Windows?

Ensure you are using the Anaconda Prompt or a terminal with conda properly initialized in the PATH. Some Windows systems require running the command prompt as Administrator to create symbolic links during the installation of packages like PyTorch. If conflicts persist, try conda env create with the --force flag after removing any existing ai4beg environment.

Can I run the notebooks without installing anything locally?

Yes, according to lessons/0-course-setup/how-to-run.md, the curriculum supports cloud execution via GitHub Codespaces or Binder. These platforms read the environment.yml configuration and provision a containerized instance with all dependencies pre-installed, allowing you to work through the lessons in a browser without local setup.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →