Setting Up the Python ML Environment: A Practical Guide
Learn how to configure your Python environment for machine learning. We cover Anaconda/venv installation, library verification, and launching Jupyter Notebooks.
Previously in this course, we explored The Machine Learning Workflow: From Data to Deployment to understand the high-level lifecycle of an AI project. Now, it’s time to move from theory to practice by building your local development environment.
A robust machine learning environment acts as the foundation for every experiment you'll run. If your tools aren't configured correctly, you’ll spend more time debugging your installation than training models. In this lesson, we will establish your workspace using standard industry tools.
Why Isolated Environments Matter
In professional software engineering, we never install libraries globally. If Project A requires NumPy 1.20 and Project B requires NumPy 1.26, a global installation will break one of them. We use isolated environments to ensure that each project has its own specific dependencies, preventing "dependency hell."
For this course, we have two primary options for environment management: Anaconda (or its lightweight version, Miniconda) or standard Python venv.
Option 1: Anaconda (Recommended for Data Science)
Anaconda is the industry standard for data science because it handles both Python packages and non-Python dependencies (like C++ libraries) seamlessly.
- Download the Miniconda installer for your operating system.
- Run the installer and follow the prompts.
- Open your terminal (or Anaconda Prompt on Windows) and verify the installation by typing
conda --version.
Option 2: venv (Standard Pythonic Approach)
If you prefer keeping your system lightweight, use the built-in venv module.
- Create a project folder:
mkdir ml-course && cd ml-course - Initialize the environment:
python -m venv .venv - Activate it:
- macOS/Linux:
source .venv/bin/activate - Windows:
.venv\Scripts\activate
- macOS/Linux:
Installing the Core ML Stack

Once your environment is active, we need to install the "Big Three" libraries that power almost every machine learning workflow: NumPy, Pandas, and Scikit-Learn.
Run the following command in your terminal:
Bashpip install numpy pandas scikit-learn jupyter
- NumPy: The foundation for numerical computing in Python.
- Pandas: Provides the DataFrame structure for data manipulation.
- Scikit-Learn: The industry-standard library for traditional machine learning algorithms.
- Jupyter: An interactive interface for running code in blocks, which is essential for data exploration and visualization.
Verifying Your Setup
Never assume an installation worked—always verify it. Create a file named verify_env.py and add the following script:
PYTHONimport numpy as np import pandas as pd import sklearn print(f"NumPy version: {np.__version__}") print(f"Pandas version: {pd.__version__}") print(f"Scikit-Learn version: {sklearn.__version__}") print("Environment setup verified successfully!")
Run this with python verify_env.py. If you see the version numbers printed without errors, your Python environment is ready.
Launching Jupyter
The Jupyter notebook environment is where we will conduct our exploratory data analysis. To launch it, run the following command in your terminal within your project directory:
Bashjupyter notebook
Your default browser should open to a local URL (usually http://localhost:8888). Create a new notebook by clicking "New" -> "Python 3". In the first cell, type print("Hello, ML!") and press Shift + Enter to execute. If the cell runs and displays the output, you are successfully configured.
Hands-on Exercise
- Create a new folder named
ml-project-rooton your machine. - Set up an isolated environment inside it (using either
condaorvenv). - Install the libraries mentioned above.
- Launch Jupyter, create a notebook, and import
pandas as pd. Create a simple dataframe with one column of numbers and display it.
Common Pitfalls

- Wrong Interpreter: The most common issue is running
pip installwhile your virtual environment is not active. Always check your command prompt for the(.venv)or(base)prefix before installing packages. - Path Conflicts: If you have multiple versions of Python installed, ensure your terminal is using the one you think it is by running
which python(macOS/Linux) orwhere python(Windows). - Kernel Mismatch: If you launch Jupyter and it says "ModuleNotFoundError," it usually means you installed the libraries in your terminal but launched Jupyter from a different Python installation. Always install Jupyter inside the environment you intend to use.
By completing this setup, you have moved past the initial friction of development. You now have a stable, reproducible environment that will serve as the sandbox for the rest of this course.
Up next: Introduction to NumPy for Data Handling.
Work with me

WooCommerce Store Setup & Customization
A WooCommerce store that's set up right, customized to your brand, and ready to sell — by a developer who builds WooCommerce products, not just stores.

VPS Server Setup, Deployment & Hardening
Get your app live on a fast, secure server — properly configured, hardened, and deployment-ready. No more wrestling with the command line.