# Key Dependencies in Microsoft AI for Beginners environment.yml

> Explore the key dependencies in the AI For Beginners environment.yml. Discover essential Jupyter, scientific computing, and PyTorch libraries for your AI projects.

- Repository: [Microsoft/AI-For-Beginners](https://github.com/microsoft/AI-For-Beginners)
- Tags: getting-started
- Published: 2026-08-28

---

**The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) file in microsoft/AI-For-Beginners defines three critical dependency groups—a core Jupyter interactive stack, scientific computing libraries with pinned versions, and PyTorch deep learning frameworks—plus a pip requirements fallback for complete curriculum support.**

The microsoft/AI-For-Beginners repository delivers a comprehensive artificial intelligence curriculum, with the [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) serving as the single source of truth for reproducible Python environments. This configuration file ensures that all notebooks and labs execute consistently across different machines by declaring exact package versions and channel sources. Understanding these key dependencies allows you to replicate the intended tutorial environment precisely on your local system.

## Core Dependencies Defined in environment.yml

The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) at the repository root organizes packages into functional groups, with specific line numbers indicating where each category appears in the source.

### Interactive Computing Stack

Lines 6-9 of [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) specify the Jupyter ecosystem required for running course notebooks:

```yaml
- ipykernel
- ipython
- ipywidgets
- jupyter

```

These packages provide the **ipykernel** execution backend, enhanced **ipython** shell capabilities, interactive **ipywidgets** for user interfaces, and the core **jupyter** notebook server.

### Scientific Computing and Visualization

Lines 10-18 define the data science toolchain with version pinning for stability:

- **matplotlib=3.9** – Publication-quality plotting
- **numpy=1.26** – Foundational numerical arrays
- **scipy=1.13** – Advanced scientific algorithms
- **scikit-learn** – Machine learning utilities
- **requests=2.32** – HTTP library for API interactions
- **opencv** (sourced from conda-forge) – Computer vision processing

Lines 12-14 and 17-18 also include **python**, **pip**, and **setuptools** to manage the base interpreter and package installation tools.

### Deep Learning Frameworks

Lines 19-22 source PyTorch packages directly from the official pytorch channel:

```yaml
- pytorch::pytorch
- pytorch::torchtext
- pytorch::torchvision
- pytorch::torchdata

```

This configuration installs the core **pytorch** tensor library alongside **torchvision** for computer vision, **torchtext** for natural language processing, and **torchdata** for composable data loading pipelines.

### Additional Pip Requirements

Line 24 references [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) via the `-r requirements.txt` syntax, allowing the environment to install additional Python packages unavailable through conda channels. This hybrid approach ensures all curriculum-specific dependencies resolve correctly regardless of their distribution source.

## How to Set Up the AI for Beginners Environment

To create the isolated `ai4beg` environment as defined in the source code:

```bash
conda env create -f environment.yml
conda activate ai4beg

```

The command reads the cross-channel specifications from [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml), resolving the pytorch channel for CUDA-enabled PyTorch builds and conda-forge for OpenCV binaries.

## Verifying Your Installation

After activation, confirm that critical dependencies import correctly with these verification snippets:

**PyTorch and CUDA check:**

```python
import torch
print(torch.__version__)
print(torch.cuda.is_available())

```

**Computer vision stack validation:**

```python
import cv2
print(cv2.__version__)

```

**Scientific plotting verification:**

```python
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2*np.pi, 100)
plt.plot(x, np.sin(x))
plt.title('Sine wave')
plt.show()

```

## Summary

- The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) in microsoft/AI-For-Beginners structures **key dependencies** into three tiers: Jupyter interaction (lines 6-9), scientific computing (lines 10-18), and PyTorch frameworks (lines 19-22).
- **Version pinning** for matplotlib=3.9, numpy=1.26, scipy=1.13, and requests=2.32 ensures tutorial reproducibility.
- **Multi-channel sourcing** pulls optimized binaries from the pytorch channel and conda-forge rather than default repositories.
- The hybrid conda-pip approach (line 24) references [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) for packages that lack conda builds.

## Frequently Asked Questions

### What Python version does the AI for Beginners environment require?

The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) specifies `python` without an explicit version constraint in the listed lines, allowing conda to resolve a compatible interpreter for the dependency set. Based on the pinned package versions (numpy=1.26, scipy=1.13) and PyTorch requirements, the environment typically resolves to Python 3.9 or higher.

### Why does the environment use specific package versions like numpy=1.26?

The microsoft/AI-For-Beginners curriculum pins **numpy=1.26**, **matplotlib=3.9**, **scipy=1.13**, and **requests=2.32** to ensure that notebook outputs remain consistent across different installation dates. These pins prevent breaking changes from newer library versions that might alter API behavior or numerical results demonstrated in the lessons.

### How do I add new packages to this environment?

Install additional packages into the active `ai4beg` environment using `conda install <package>` for conda-available libraries, or `pip install <package>` for PyPI-only dependencies. If the package is required for a curriculum contribution, append it to [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) (referenced on line 24) or add it directly to the dependency list in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) with an appropriate version pin.

### Can I run the curriculum without using the environment.yml file?

While possible, running notebooks without the [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) configuration risks version incompatibilities, particularly with the **pytorch** channel packages and **opencv** conda-forge builds defined in lines 19-22. The specific channel declarations ensure you receive GPU-enabled PyTorch binaries and properly compiled OpenCV libraries that may differ from standard pip installations.