Skip to content
TutorialsA part of Coaley Peak®
TutorialAI Coding & Development

Setting Up Python for AI Development

A step-by-step guide to setting up Python on your computer for AI and machine learning projects. Covers installation, virtual environments, and key libraries.

AI Coding & DevelopmentIntermediate
7 min readLast updated 15 April 2026By
What you will learn
  • Install Python on Windows, macOS, or Linux
  • Set up a virtual environment for AI projects
  • Install core AI libraries with pip
  • Verify your setup with a test script

Python is the most popular language for AI development. Most AI libraries, tutorials, and tools are built for Python first. Before you can start building AI projects, you need to set up Python properly on your computer. This guide walks you through every step.

Installing Python#

If you do not already have Python installed, follow these steps for your operating system.

Windows:

  1. Download Python from the official Python website
  2. Run the installer
  3. Tick the box that says "Add Python to PATH", this is important
  4. Click "Install Now"
  5. Open Command Prompt and type python --version to confirm it installed

macOS:

  1. macOS comes with an older Python version. Install the latest version using Homebrew
  2. Open Terminal and run:
brew install python
  1. Verify with python3 --version

Linux:

Most Linux distributions include Python. Check your version with python3 --version. If you need to install or update it:

sudo apt update
sudo apt install python3 python3-pip python3-venv

Use Python 3.10 or newer

AI libraries require Python 3.10 or later. Check your version before installing libraries. If you have an older version, update it first.

Setting up a virtual environment#

A virtual environment keeps your AI project's libraries separate from your other Python projects. This prevents version conflicts.

Create a virtual environment:

python3 -m venv my-ai-project

Activate it:

# macOS / Linux
source my-ai-project/bin/activate

# Windows
my-ai-project\Scripts\activate

When the environment is active, you will see the environment name in brackets at the start of your terminal prompt, like (my-ai-project).

To deactivate when you are finished:

deactivate

Always use virtual environments

Installing AI libraries globally can cause conflicts between projects. Always create a virtual environment for each project. It takes seconds and prevents hours of debugging.

Installing essential AI libraries#

With your virtual environment active, install the core libraries you will need. Use pip, which is Python's package manager:

pip install numpy pandas matplotlib scikit-learn jupyter

Here is what each library does:

LibraryPurpose
NumPyMathematical operations on arrays and matrices
PandasWorking with data in tables (like spreadsheets)
MatplotlibCreating charts and visualisations
scikit-learnMachine learning algorithms for classification, regression, and clustering
JupyterInteractive notebooks for writing and running code in your browser

For deep learning projects, you will also want:

pip install torch transformers
  • PyTorch is a popular deep learning framework
  • Transformers by Hugging Face gives you access to pre-trained AI models

Testing your setup#

Create a quick test to make sure everything works. Start a Jupyter notebook:

jupyter notebook

This opens a browser window. Create a new notebook and run this code:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris

# Load a sample dataset
iris = load_iris()
df = pd.DataFrame(iris.data, columns=iris.feature_names)

# Show the first few rows
print(df.head())

# Create a simple chart
df.hist(figsize=(10, 8))
plt.tight_layout()
plt.show()

print("Setup complete. All libraries working.")

If you see a table of data and a set of charts, your setup is working correctly.

Next steps#

With your environment ready, you can:

  • Work through machine learning tutorials using scikit-learn
  • Experiment with pre-trained AI models using the Transformers library
  • Build your own data analysis projects with Pandas
  • Start learning about neural networks with PyTorch

Key takeaways#

  • Python 3.10 or newer is required for modern AI libraries
  • Always use a virtual environment for each project
  • The core libraries for AI are NumPy, Pandas, Matplotlib, scikit-learn, and Jupyter
  • For deep learning, add PyTorch and Transformers
  • Test your setup with a simple script before starting a project
Key takeaways
  • Installing Python
  • Setting up a virtual environment
  • Installing essential AI libraries
  • Testing your setup
  • Next steps
Next in Build with AI

Best AI Tools for Beginners in 2026

Continue
For your team

Useful? Now picture your whole team knowing it.

Everything here is free, and the first course is too: eight short online lessons your team can start this afternoon. When you want the skills to stick, we come to you for a day on-site, built around the work your people actually do.

Ready to go deeper?

Build on what you have learned

Carry on with a structured learning path: tutorials set in the right order, free, with a certificate at the end.