AI-assisted Python Coding
Setting up your Python environment
Setting up your Python environment
Two main options:
- CIP-Pool or jupyter-Server of the faculty of physics and astronomy
- Local installation on your computer
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:
Verify:
Step 1: Install Python (Linux)
For Ubuntu / Debian:
sudo apt update
sudo apt install python3 python3-pip python3-venv
Verify:
For other distributions, install equivalent packages for: - python3 - pip - venv
Step 1: Install Python (Windows)
- Go to python.org/downloads
- Download the latest Python 3 installer for Windows.
- Start installer and check
Add Python to PATH.
- Click
Install Now.
Verify in Command Prompt or PowerShell:
If py is not available, try:
Step 2: Install VS Code + Python extension
- Install VS Code: code.visualstudio.com
- Open VS Code and go to Extensions.
- Search for
Python by Microsoft.
- Install extension.
Optional but useful:
- Jupyter extension (for notebooks)
Step 3: Create course folder
Create a folder, for example:
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:
macOS / Linux:
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:
Expected output:
Optional: Start Jupyter locally
or
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
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.