AI-assisted Python Coding

Setting up your Python environment

Klaus Reygers

Setting up your Python environment

Two main options:

Local setup: Goal

It would be useful if you already have this installed before the first session. If not, we will set it up together in the first class:

  • Python 3.11 (or newer)
  • VS Code + Python extension
  • A local project folder
  • A virtual environment (.venv)
  • A successful test run in terminal

Step 1: Install Python (macOS)

Recommended: install via Homebrew.

If Homebrew is not installed:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install Python:

brew install python

Verify:

python3 --version

Step 1: Install Python (Linux)

For Ubuntu / Debian:

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

Verify:

python3 --version

For other distributions, install equivalent packages for: - python3 - pip - venv

Step 1: Install Python (Windows)

  1. Go to python.org/downloads
  2. Download the latest Python 3 installer for Windows.
  3. Start installer and check Add Python to PATH.
  4. Click Install Now.

Verify in Command Prompt or PowerShell:

py --version

If py is not available, try:

python --version

Step 2: Install VS Code + Python extension

  1. Install VS Code: code.visualstudio.com
  2. Open VS Code and go to Extensions.
  3. Search for Python by Microsoft.
  4. Install extension.

Optional but useful:

  • Jupyter extension (for notebooks)

Step 3: Create course folder

Create a folder, for example:

python-course/

Open this folder in VS Code (File -> Open Folder...).

Step 4: Create virtual environment

In the VS Code terminal, run one of the following:

Windows:

py -m venv .venv

macOS / Linux:

python3 -m venv .venv

Step 4: Activate virtual environment

Windows PowerShell:

.venv\Scripts\Activate.ps1

Windows Command Prompt:

.venv\Scripts\activate.bat

macOS / Linux:

source .venv/bin/activate

You should see (.venv) at the beginning of the terminal prompt.

Step 5: Install basic packages

With active .venv:

python -m pip install --upgrade pip
python -m pip install jupyter numpy pandas matplotlib

If your shell does not recognize python, use python3.

Step 6: Test your setup

Create file hello.py with:

print("Hello Python course!")

Run:

python hello.py

Expected output:

Hello Python course!

Optional: Start Jupyter locally

jupyter notebook

or

jupyter lab

Optional: GitHub Copilot for students

As a student, you can apply for free GitHub Copilot access.

Useful links:

Recommendation:

  • Do this after basic Python setup is complete.

Also check: Local chatbot (Uni Heidelberg)

Please also test the local chatbot:

Use cases in this course:

  • quick Python questions
  • brainstorming ideas
  • code generation (but check results carefully!)

Troubleshooting

  • Command not found:
    • Try python3 instead of python (macOS/Linux).
    • Re-open terminal after installation.
  • VS Code uses wrong interpreter:
    • Cmd/Ctrl+Shift+P -> Python: Select Interpreter -> choose .venv.
  • PowerShell blocks activation scripts:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

Then try activation again.

What to bring to class

  • Laptop + charger

And (if possible):

  • Working Python installation
  • VS Code installed
  • Working terminal
  • Working Eduroam Wi-Fi access

If local setup fails, use the faculty Jupyter server for the first session and fix local setup afterwards.