How to Set Up the Conda Environment for AI-For-Beginners Locally
Create a reproducible Python environment for Microsoft's AI curriculum using the provided 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 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.
- Download the Miniconda installer for your operating system from conda.io
- Run the installer and follow the prompts
- Verify installation by opening a terminal and running
conda --version
Clone the Repository and Locate the Environment File
The 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, this file ensures dependency compatibility across all 24+ lessons.
Clone the repository and navigate to it:
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:
conda env create --name ai4beg --file environment.yml
This command reads 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:
conda activate ai4beg
Launch Jupyter and Start Learning
With the conda environment for AI-For-Beginners active, you can now run the interactive notebooks:
jupyter notebook
Or use JupyterLab for a more modern interface:
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 - Run
conda env create --name ai4beg --file environment.ymlto build the environment - Activate with
conda activate ai4begand launch Jupyter or VS Code
The 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 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 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 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 may work, Microsoft explicitly supports and tests the conda workflow. The 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.
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 →