MANUAL

Installing Python

01 / INSTALLATION

Installing Python.

Python is a programming language for scripting, data and automation. Your AI assistant often uses it for small utilities. Always install a Python 3 version.

01 / Windows

  1. Go to python.org/downloads and download the latest version for Windows.
  2. Open the installation file.
  3. Tick the box at the bottom labelled Add python.exe to PATH. This is important.
  4. Click on Install Now.
  5. Reopen PowerShell and check:
python --version

Can you see a version number starting with 3? If so, Python is installed. Does the Microsoft Store open instead? If so, the PATH option wasn’t ticked. Reinstall and make sure to tick it this time.

02 / Linux

Python is already installed on most versions of Linux. Check:

python3 --version

Are you missing it, or are you missing pip and venv? Choose the command for your version of Linux.

Ubuntu / Debian / Linux Mint

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

Fedora

sudo dnf install python3 python3-pip

Arch Linux

sudo pacman -S python python-pip

On Linux, you type python3, whereas Windows uses python.

02 / PER PROJECT

A virtual environment.

A virtual environment (venv) is a separate folder containing the Python packages for a single project. This ensures that projects do not interfere with one another.

03 / Create an environment

Open the terminal in your project folder:

Windows

python -m venv .venv

Linux

python3 -m venv .venv

04 / Turn on the environment

Windows

.venv\Scripts\Activate.ps1

Linux

source .venv/bin/activate

You should now see (.venv) before the line. Are you getting a message about scripts on Windows? See the manual ‘The Terminal and PowerShell’, section 11.

05 / Turn off the surroundings

deactivate

03 / PACKAGES

Installing additional features.

You use pip to install packages: ready-to-use code written by others. NumPy (data processing) and Matplotlib (graphs) are the most commonly searched for.

06 / Installing a package

First, start the environment, then run the following:

pip install numpy matplotlib

07 / Identifying which packages you use

pip freeze > requirements.txt

Add this file to Git. You can then install everything in one go on another computer:

pip install -r requirements.txt

08 / Running a script

python mijn_script.py

On Linux: python3 mijn_script.py if the environment is not set up.

04 / WORKING WITH AI

Ask your assistant.

09 / A task for your AI assistant

"Check that Python 3 is installed, create a virtual environment for this project and install the packages listed in requirements.txt. Ask for permission before installing anything."

Good to know

Never commit the .venv directory to Git. Add .venv/ to the .gitignore file. Do not install packages using sudo pip.