# Environment.yml vs requirements.txt in Microsoft AI-For-Beginners: Frameworks and Versions Compared

> Compare environment.yml and requirements.txt in Microsoft AI-For-Beginners. Understand Conda vs Pip dependencies and framework version control for your AI projects.

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

---

**The Microsoft AI-For-Beginners repository splits its Python dependencies across two files: [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) manages Conda-installed base packages with partial version pinning (NumPy 1.26, SciPy 1.13) while leaving PyTorch unpinned, whereas [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) enforces strict versions for Pip-installed frameworks including TensorFlow 2.17.0, Keras 3.13.2, and the Hugging Face ecosystem.**

Setting up the Microsoft AI-For-Beginners curriculum requires understanding exactly which frameworks and versions are specified in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) versus [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) to ensure reproducible machine learning environments. While both files define dependencies necessary for the beginner AI lessons, they serve distinct architectural purposes—[`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) handles system-level binaries and GPU drivers through Conda channels, while [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) controls pure-Python libraries through Pip. This dual-file strategy allows the repository to balance hardware flexibility for CUDA installations with strict reproducibility for high-level ML frameworks.

## Conda-Managed Frameworks in environment.yml

The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) file at the repository root establishes the base Conda environment, mixing precisely pinned scientific libraries with flexible deep-learning dependencies that allow the solver to optimize for specific GPU or CPU configurations.

### Precisely Pinned Core Libraries

Lines 10-12 of [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) explicitly pin four foundational libraries to ensure numerical reproducibility across all platforms:

- `matplotlib=3.9` for data visualization
- `numpy=1.26` for numerical computing
- `requests=2.32` for HTTP library support
- `scipy=1.13` for scientific computing routines

### Unpinned GPU and Vision Libraries

Unlike the scientific core, the deep learning frameworks listed in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) omit version specifications to let Conda resolve the most compatible builds for your hardware:

- `pytorch::pytorch` (line 19)
- `pytorch::torchtext` (line 20)
- `pytorch::torchvision` (line 21)
- `pytorch::torchdata` (line 22)
- `conda-forge::opencv` (line 17) for computer vision utilities

## Pip-Managed Frameworks in requirements.txt

While [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) handles the Conda ecosystem, lines 23-24 delegate additional package management to Pip via the `-r requirements.txt` directive. This file contains exclusively pinned versions using `==` syntax to guarantee identical installations across Windows, macOS, and Linux.

### Deep Learning and TensorFlow Stack

The [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) file specifies exact builds for Google's deep learning stack and supporting tools:

- `tensorflow==2.17.0` (line 16)
- `keras==3.13.2`
- `tensorboard==2.17.1`
- `tensorflow-datasets==4.9.6`
- `tensorflow-hub==0.16.1`
- `tensorboard-data-server==0.7.2`

### NLP, Reinforcement Learning, and Utilities

Natural language processing and reinforcement learning dependencies include strictly versioned packages:

- `gensim==4.3.3` for word embeddings
- `nltk==3.10.0` for text processing
- `tokenizers==0.20.0` for Hugging Face tokenization
- `huggingface==0.0.1` for transformer utilities
- `gym==0.26.2` for reinforcement learning environments
- `torchinfo==1.8.0` for PyTorch model summaries

Additional pinned data science utilities include `pandas==2.2.2`, `pillow==12.2.0`, `scikit-image==0.24.0`, `seaborn==0.13.2`, `imageio==2.35.0`, `pygame==2.6.0`, `smart-open==7.0.4`, and `tqdm==4.66.5`.

## Critical Differences in Version Specification Strategy

Understanding why certain frameworks and versions are specified in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) versus [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) reveals the repository's architectural decisions regarding dependency resolution.

**Scope Separation:** [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) manages system-level binaries, CUDA drivers, and compiled libraries through Conda's channel system (including `conda-forge` and `pytorch` channels). In contrast, [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) handles pure-Python machine learning frameworks that Pip distributes more efficiently, ensuring exact version parity across different operating systems.

**Version Pinning Philosophy:** Conda entries use exact pins only for the scientific stack (NumPy, SciPy, Matplotlib) that directly affect numerical precision and API stability, while leaving PyTorch and OpenCV unpinned to accommodate diverse GPU architectures and driver versions. Conversely, every entry in [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) uses strict equality (`==`) to eliminate dependency drift in the high-level ML frameworks.

## Installation and Verification Workflow

Deploy the environment using the Conda-first approach defined in the source files, which automatically cascades to Pip for the strictly pinned components.

```bash

# Create the environment from the root directory

conda env create -f environment.yml

# Activate the environment

conda activate ai4beg

# Verify key framework versions match the specifications

python -c "import numpy, matplotlib, tensorflow as tf; \
print(f'NumPy: {numpy.__version__}'); \
print(f'Matplotlib: {matplotlib.__version__}'); \
print(f'TensorFlow: {tf.__version__}')"

```

```python

# Verify a requirements.txt package (strictly pinned)

import gensim
print(gensim.__version__)  # Output: 4.3.3

```

```python

# Verify a Conda-managed package (solver-determined version)

import torch
print(torch.__version__)  # Version determined by Conda resolver based on your hardware

```

## Summary

- **Microsoft AI-For-Beginners** uses a hybrid dependency strategy splitting frameworks and versions between [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) (Conda) and [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) (Pip) to balance hardware flexibility with reproducibility.
- **[`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml)** pins core scientific libraries to specific versions (NumPy 1.26, SciPy 1.13, Matplotlib 3.9) but leaves PyTorch and OpenCV unpinned for Conda's solver optimization.
- **[`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt)** enforces strict equality for all 20+ frameworks, including TensorFlow 2.17.0, Keras 3.13.2, Pandas 2.2.2, and the Hugging Face ecosystem.
- The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) references [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) at lines 23-24 using `-r requirements.txt`, creating a unified installation workflow when running `conda env create`.

## Frequently Asked Questions

### Why does AI-For-Beginners use both environment.yml and requirements.txt?

The repository uses [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) to install system-level dependencies and GPU drivers through Conda channels like `pytorch` and `conda-forge`, while [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) manages pure-Python machine learning frameworks that are more efficiently distributed via Pip. This hybrid approach ensures CUDA compatibility through Conda's binary management while maintaining precise version control for TensorFlow and Keras through Pip's strict pinning.

### Which file should I modify to update TensorFlow versions?

Update TensorFlow in [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) where it is strictly pinned as `tensorflow==2.17.0` on line 16. Changing it here ensures Pip installs the exact specified version after Conda creates the base environment. The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) delegates to this file via the `-r requirements.txt` directive at lines 23-24, so modifications automatically propagate during environment creation.

### Are PyTorch versions pinned in the AI-For-Beginners repository?

No, the PyTorch family (`pytorch`, `torchvision`, `torchtext`, `torchdata`) listed in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) lines 19-22 does not specify version numbers. This allows Conda's dependency solver to select the most compatible version for your specific CUDA or CPU configuration, unlike the strictly pinned Pip packages in [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt).

### How do I verify which version of NumPy was installed?

NumPy is pinned to version 1.26 in [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) line 11. After activating the `ai4beg` environment, run `python -c "import numpy; print(numpy.__version__)"` to confirm the installation matches the specified version.