Python AI Development Environment
Before building AI applications, you need a proper development environment. This chapter guides you through installing Python, setting up virtual environments, and installing the essential AI libraries.
Install Python
Download and install Python from python.org. We recommend Python 3.10 or newer.
# Check Python version
python3 --version
# Check pip version
pip3 --version
Create a Virtual Environment
Virtual environments isolate your project dependencies so they don't conflict with other projects.
# Create a virtual environment
python3 -m venv ai-env
# Activate on macOS/Linux
source ai-env/bin/activate
# Activate on Windows
ai-env\Scripts\activate
Install Essential AI Libraries
# Core data science
pip install numpy pandas matplotlib seaborn
# Machine learning
pip install scikit-learn
# Deep learning
pip install tensorflow torch torchvision
# Computer vision
pip install opencv-python pillow
# Natural language processing
pip install nltk spacy transformers
# Jupyter for interactive development
pip install jupyterlab
Verify Installation
import numpy as np
import pandas as pd
import sklearn
import torch
import tensorflow as tf
print("NumPy:", np.__version__)
print("Pandas:", pd.__version__)
print("Scikit-learn:", sklearn.__version__)
print("PyTorch:", torch.__version__)
print("TensorFlow:", tf.__version__)
Using Jupyter Notebook
Jupyter Notebook is perfect for AI development because you can run code cells interactively and see results immediately.
jupyter notebook
Summary
Your Python AI environment is now ready. In the next chapter, we'll cover core AI concepts that you need to understand before building models.