AI for Beginners Environment.yml Dependencies: Complete Guide to the Microsoft Curriculum Stack
The AI for Beginners environment.yml defines a hybrid Conda-and-pip environment featuring PyTorch, TensorFlow, scikit-learn, Jupyter, and 15+ core packages required to run the Microsoft's open-source AI curriculum.
The environment.yml file in the Microsoft/AI-For-Beginners repository orchestrates a reproducible machine learning environment that powers every notebook in the 24-lesson curriculum. Located at the repository root, this Conda configuration combines binary-optimized packages with a pip-managed requirements file to support both deep learning frameworks (PyTorch and TensorFlow) and interactive development tools.
Core Dependencies in the AI for Beginners Environment.yml
The primary environment.yml ([environment.yml](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml)) at lines 6-24 specifies the following foundational packages:
Interactive Development Stack
ipykernel— Enables Jupyter kernels to execute Python code inside notebook cellsipython— Provides the enhanced interactive Python shell underlying notebook sessionsipywidgets— Supplies interactive UI elements (sliders, buttons, dropdowns) for demonstrationsjupyter— The notebook server that launches the browser-based interactive interface
These four packages (lines 6-9) form the complete Jupyter ecosystem used throughout the curriculum's hands-on exercises.
Scientific Computing Foundation
numpy = 1.26(line 11) — Fundamental array-processing library; the numerical backbone of virtually every ML operationscipy = 1.13(line 15) — Scientific computing tools for linear algebra, optimization, and signal processingmatplotlib = 3.9(line 10) — Core plotting library for visualizing datasets, training curves, and model outputsscikit-learn(line 14) — Classical machine learning algorithms, preprocessing utilities, and evaluation metrics
The pinned versions of NumPy, SciPy, and Matplotlib ensure compatibility across different operating systems and prevent breaking changes from upstream updates.
Deep Learning Framework
pytorch(line 19, pytorch channel) — Core deep learning tensor library and autograd enginetorchvision(line 21) — Computer vision datasets, image transforms, and pretrained ResNet/VGG modelstorchtext(line 20) — Text processing utilities, tokenizers, and NLP datasetstorchdata(line 22) — Composable data-loading pipelines that integrate with torchtext and torchvision
These PyTorch ecosystem packages are sourced from the official pytorch Conda channel rather than the default channel, ensuring optimized CUDA builds for GPU acceleration where available.
Computer Vision and Data Access
opencv(line 17, conda-forge) — OpenCV library for image loading, resizing, color space conversion, and video processingrequests = 2.32(line 13) — HTTP client library used by notebooks to download datasets and interact with web APIs
OpenCV from conda-forge provides precompiled binaries that avoid common pip installation issues on Windows and macOS.
Build and Package Management
pip(line 16) — Included as a Conda package to enable thepip:blocksetuptools(line 18) — Build utilities required for compiling certain Python packages from sourcepython(line 12) — Specifies Python interpreter availability (version unconstrained to use latest compatible)
Hybrid Environment Architecture: Conda + Pip
The AI for Beginners environment.yml implements a two-tier dependency strategy (lines 16-24):
pip:
- -r requirements.txt
This pip: block delegates additional package installation to the separate [requirements.txt](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) file. According to the Microsoft/AI-For-Beginners source code, this hybrid approach achieves:
- Binary reliability — Conda handles complex native dependencies (PyTorch's CUDA kernels, OpenCV's image codecs)
- Package freshness — Pip installs rapidly-evolving ML libraries (TensorFlow 2.x, Keras 3) without waiting for Conda builds
- Cross-platform consistency — Synchronized lockfiles ensure identical environments on Windows, macOS, and Linux
Creating and Activating the Environment
Execute these commands to replicate the exact environment defined in environment.yml:
# Create the environment from the curriculum definition
conda env create -f environment.yml
# Activate the environment (name defaults to project directory or explicit name)
conda activate ai4beg
# Verify key frameworks import correctly
python -c "import torch, cv2, sklearn, numpy; print(f'PyTorch {torch.__version__}, NumPy {numpy.__version__}')"
# Launch the interactive notebook server
jupyter notebook
The environment name ai4beg is defined implicitly; check environment.yml for an explicit name: field if the activation fails.
Binder-Specific Environment Variant
The repository maintains a second environment definition at [binder/environment.yml](https://github.com/microsoft/AI-For-Beginners/blob/main/binder/environment.yml) for cloud deployment. This variant:
- Pins exact versions of all packages for reproducible Binder builds
- Removes platform-specific build constraints incompatible with the Binder container runtime
- References the same
requirements.txtpip dependencies
Use this file instead when launching via mybinder.org:
conda env create -f binder/environment.yml
Complete Dependency File Reference
| File | Purpose | Location |
|---|---|---|
environment.yml |
Primary Conda environment for local development | Repository root |
binder/environment.yml |
Cloud-optimized variant with explicit version pins | binder/ subdirectory |
requirements.txt |
Pip-only packages (TensorFlow, Keras, etc.) | Repository root |
README.md |
Setup instructions referencing these files | Repository root |
Summary
- The AI for Beginners
environment.ymlspecifies 14 direct Conda dependencies plus a pip requirements file - PyTorch and its ecosystem (torchvision, torchtext, torchdata) provide the primary deep learning framework
- NumPy 1.26, SciPy 1.13, and Matplotlib 3.9 are pinned for stability across the 24-lesson curriculum
- The hybrid Conda-pip architecture balances binary reliability with access to cutting-edge ML packages
- A separate Binder environment file ensures reproducible cloud deployments with exact version constraints
Frequently Asked Questions
What deep learning frameworks are included in the AI for Beginners environment?
The environment.yml installs PyTorch as its primary deep learning framework, including the full ecosystem (torchvision, torchtext, torchdata). TensorFlow and Keras are installed via the pip requirements file referenced in the pip: -r requirements.txt block at line 23-24. This dual-framework approach supports lessons using either PyTorch or TensorFlow code examples.
Why does the environment use both Conda and pip?
The Microsoft/AI-For-Beginners source code uses Conda for packages requiring complex binary compilation (PyTorch with CUDA, OpenCV image codecs) while delegating to pip for pure-Python packages that update frequently (TensorFlow 2.x, Keras 3). This hybrid method avoids common installation failures while maintaining access to the latest ML library versions.
How do I troubleshoot import errors after creating the environment?
First verify activation with conda activate ai4beg (or your specified environment name). Then check individual imports: python -c "import torch, tensorflow as tf, cv2, sklearn". If TensorFlow fails, the pip requirements.txt installation may have been skipped—run pip install -r requirements.txt manually. Platform-specific OpenCV issues usually resolve by reinstalling from conda-forge: conda install -c conda-forge opencv.
What Python version does the AI for Beginners environment use?
The environment.yml (line 12) lists python without an explicit version constraint, which allows Conda to select the latest compatible Python version for the dependency set. The pinned NumPy 1.26 and SciPy 1.13 versions currently constrain this to Python 3.9-3.11. For exact Python version requirements, check the binder/environment.yml variant which specifies explicit interpreter versions.
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 →