# How to Set Up the Conda Environment for AI-For-Beginners Locally

> Set up the conda environment for AI-For-Beginners locally. Follow our guide to install AI-For-Beginners dependencies using four simple conda commands and the environmentyml file for a reproducible Python setup.

- Repository: [Microsoft/AI-For-Beginners](https://github.com/microsoft/AI-For-Beginners)
- Tags: how-to-guide
- Published: 2026-08-25

---

**Create a reproducible Python environment for Microsoft's AI curriculum using the provided [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) file and four simple conda commands.**

The **AI-For-Beginners** repository from Microsoft provides a comprehensive, notebook-based curriculum for learning artificial intelligence. To run these lessons locally without dependency conflicts, you need a properly configured Python environment. According to the source code, the recommended approach uses **conda** with the supplied [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) file to install all required packages—including TensorFlow, PyTorch, Jupyter, and computer vision libraries—in one reproducible step.

## Prerequisites: Install Miniconda

Before setting up the AI-For-Beginners environment, you need the **conda** package manager. Microsoft recommends **Miniconda**, a minimal distribution that includes only conda and its dependencies.

1. Download the Miniconda installer for your operating system from [conda.io](https://conda.io/en/latest/miniconda.html)
2. Run the installer and follow the prompts
3. Verify installation by opening a terminal and running `conda --version`

## Clone the Repository and Locate the Environment File

The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) file in the repository root defines the exact package set tested by the curriculum maintainers. As documented in [`lessons/0-course-setup/how-to-run.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/how-to-run.md), this file ensures **dependency compatibility** across all 24+ lessons.

Clone the repository and navigate to it:

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

```

## Create and Activate the Conda Environment

With Miniconda installed and the repository cloned, create the environment using the specification in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml):

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

```

This command reads [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) from the AI-For-Beginners root directory and installs all listed dependencies—including `ipykernel`, `jupyter`, `numpy`, `tensorflow`, `pytorch`, `opencv`, and supporting libraries—into an isolated environment named **ai4beg**.

Activate the environment to use it:

```bash
conda activate ai4beg

```

## Launch Jupyter and Start Learning

With the conda environment for AI-For-Beginners active, you can now run the interactive notebooks:

```bash
jupyter notebook

```

Or use **JupyterLab** for a more modern interface:

```bash
jupyter lab

```

The `ai4beg` kernel automatically appears in Jupyter's kernel selector, ensuring all imported libraries resolve correctly.

## Alternative: Use VS Code with the Python Extension

For an enhanced editing experience, open the AI-For-Beginners folder in **VS Code** after activating the environment. The Python extension detects the `ai4beg` kernel and offers to install any missing extensions for notebook support. This workflow combines conda environment isolation with IDE features like IntelliSense and debugging.

## Summary

Setting up the conda environment for AI-For-Beginners locally requires four steps:

- Install **Miniconda** to obtain the conda package manager
- **Clone the repository** to access the curriculum and [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml)
- Run `conda env create --name ai4beg --file environment.yml` to build the environment
- **Activate** with `conda activate ai4beg` and launch Jupyter or VS Code

The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) approach guarantees that your local setup matches the tested configuration used in Microsoft's official curriculum, eliminating version conflicts between TensorFlow, PyTorch, and supporting libraries.

## Frequently Asked Questions

### What packages are included in the AI-For-Beginners conda environment?

The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) file specifies core machine learning frameworks including **TensorFlow**, **PyTorch**, **NumPy**, and **OpenCV**, plus Jupyter infrastructure (`jupyter`, `ipykernel`) for running interactive notebooks. The complete list is maintained in the root [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) file and updated as the curriculum evolves.

### Can I use a different environment name instead of "ai4beg"?

Yes. Replace `ai4beg` with your preferred name in the `conda env create` command: `conda env create --name myenv --file environment.yml`. However, documentation in [`README.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/README.md) and setup guides reference `ai4beg`, so using that name simplifies following official instructions.

### How do I update the environment when the curriculum adds new dependencies?

Navigate to your AI-For-Beginners directory, pull the latest changes with `git pull`, then update your environment: `conda env update --name ai4beg --file environment.yml --prune`. The `--prune` flag removes packages no longer needed, keeping your environment clean and matching the current curriculum requirements.

### Is conda required, or can I use pip and a virtual environment?

While `pip` with [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) may work, Microsoft explicitly supports and tests the **conda** workflow. The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) includes conda-specific packages and channel configurations that pip cannot replicate. For guaranteed compatibility with AI-For-Beginners lessons, conda is the recommended approach per [`lessons/0-course-setup/how-to-run.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/how-to-run.md).