Environment.yml vs requirements.txt in Microsoft AI-For-Beginners: Frameworks and Versions Compared
The Microsoft AI-For-Beginners repository splits its Python dependencies across two files: environment.yml manages Conda-installed base packages with partial version pinning (NumPy 1.26, SciPy 1.13) while leaving PyTorch unpinned, whereas 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 versus 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 handles system-level binaries and GPU drivers through Conda channels, while 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 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 explicitly pin four foundational libraries to ensure numerical reproducibility across all platforms:
matplotlib=3.9for data visualizationnumpy=1.26for numerical computingrequests=2.32for HTTP library supportscipy=1.13for scientific computing routines
Unpinned GPU and Vision Libraries
Unlike the scientific core, the deep learning frameworks listed in 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 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 file specifies exact builds for Google's deep learning stack and supporting tools:
tensorflow==2.17.0(line 16)keras==3.13.2tensorboard==2.17.1tensorflow-datasets==4.9.6tensorflow-hub==0.16.1tensorboard-data-server==0.7.2
NLP, Reinforcement Learning, and Utilities
Natural language processing and reinforcement learning dependencies include strictly versioned packages:
gensim==4.3.3for word embeddingsnltk==3.10.0for text processingtokenizers==0.20.0for Hugging Face tokenizationhuggingface==0.0.1for transformer utilitiesgym==0.26.2for reinforcement learning environmentstorchinfo==1.8.0for 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 versus requirements.txt reveals the repository's architectural decisions regarding dependency resolution.
Scope Separation: 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 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 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.
# 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__}')"
# Verify a requirements.txt package (strictly pinned)
import gensim
print(gensim.__version__) # Output: 4.3.3
# 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(Conda) andrequirements.txt(Pip) to balance hardware flexibility with reproducibility. environment.ymlpins 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.txtenforces 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.ymlreferencesrequirements.txtat lines 23-24 using-r requirements.txt, creating a unified installation workflow when runningconda env create.
Frequently Asked Questions
Why does AI-For-Beginners use both environment.yml and requirements.txt?
The repository uses environment.yml to install system-level dependencies and GPU drivers through Conda channels like pytorch and conda-forge, while 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 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 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 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.
How do I verify which version of NumPy was installed?
NumPy is pinned to version 1.26 in 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.
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 →