Python for AILesson 1
Lesson 16 min
Setup Python
Install Python and use a clean virtual environment.
What you will learn
- ✓Why virtual environments matter
- ✓Creating and activating a venv
- ✓Installing AI libraries with pip
Explanation
Python is the default language for AI because of its huge library ecosystem. First, install Python 3 from python.org.
Always work inside a virtual environment (venv) — an isolated folder of packages for each project. This stops one project's library versions from breaking another's.
Create one, activate it, then install the core data libraries. You will see (.venv) in your terminal when it is active.
Code Example
bash
| 1 | |
| 2 | |
| 3 | |
Real-world use
Every professional Python project uses isolated environments — it is the difference between 'works on my machine' and reproducible setups.
Common mistakes
- • Installing packages globally and later hitting version conflicts between projects.
Practice
Create a venv, activate it, and install numpy. Confirm with `pip list`.
Knowledge check
0/1 answered1. Why use a virtual environment?
Answer all questions to check.