Before writing code, you need a setup that is predictable and easy to use. This module assumes that participants work with:
- VS Code as the main editor (IDE),
- Miniforge to manage Python environments,
- Jupyter Notebooks for interactive exercises,
- a terminal for running commands explicitly.
A good environment helps you avoid several common beginner problems:
- using the wrong Python installation,
- mixing project dependencies together,
- not knowing where packages were installed,
- running code in one tool but editing another.
In general:
- Enhance reproducability
- Changes/package installations do not influence main Python installation
- If something breaks, you do not have to reinstall everything, just recreate the virtual environment
The goal is not to memorize every tool immediately. The goal is to create a setup you can trust.
For a standard BAM setup, make sure you have:
- Miniforge installed for your user account.
- VS Code installed, with additional extensions (which install more extensions they depend on, 9 in sum):
- Python extension by Microsoft
- Jupyter extension by Microsoft
- A GitHub account ready for the course.
If BAM-specific installers are distributed through the software portal, prefer those versions unless the course team recommends otherwise.
Virtual environments are used to handle coding projects individually. Using one environment per project or purpose is a healthy default. There are mainly two options:
A virtual environment venv which is purely Python-based. It comes as a module in each Python installation and it can manage multiple environments (in local folders) with an independet set of packages in each. But they are bound to the Python version, venv is running with. This is the minimal and fast variant.
python -m venv .venv
source .venv/bin/activateA conda environment, managed by MiniForge. It has the benefit to manage more than just Python packages. It can install system application with binaries (non-Python based) as well and it lets you install different Python versions in each environment which is great when dealing with older code or apps.
For this course, Miniforge and conda are a practical starting point. You create a Jupyter-focused environment like this:
conda create --name jlab python=3.12
conda activate jlab
conda install jupyterlab notebook numpy scipy pandas matplotlib openpyxl lmfit- Basically, you can write Python code in every sinple text editor (Notepad, Notepad++, vim, Kate, ...)
- Using „Integrated Development Environments“ (IDEs) is often preferred:
- Software designed for writing code
- Nice formatting
- Easy usability
- A lot of automatic integrations, assistence functions
- Visual Studio Code (VSCode) is an IDE developed by Microsoft
- It is available for Windows, Linux and macOS
- It is widely used and available in BAMs Software Portal
After installation:
- Open VS Code.
- Make sure, at least the Python extension from Microsoft is installed.
- Open your working folder, or create a new one.
- Select the Python interpreter from your Miniforge environment created above.
Once the interpreter is selected correctly, the terminal, script runner, and notebook support in VS Code will all become much more consistent.
Notebooks are an interactive computing environment used mainly for data analysis, scientific computing, and coding education. They let you write code, run it, and see the results — all in one document. A Jupyter Notebook combines three things in a single file:
- Code (usually Python, but also R, Julia, etc.)
- Text explanations (formatted with Markdown)
- Output (charts, tables, images, printed results)
This makes them extremely useful for explaining your work step by step. A notebook is made up of cells:
- Code cells → where you write and run code
- Markdown cells → where you write text, notes, or explanations
When you run a code cell, the output appears directly below it.
A simple Python example in a notebook:
x = 5
y = 3
x + yOutput:
8
→ You can immediately see the result without needing a separate output window.
Notebooks are saved as .ipynb. This file contains all code, text, and outputs.
They are useful when you want to:
- experiment with code step by step,
- mix explanation and code in one place,
- show results such as tables or plots immediately,
- teach interactively during a live session.
They are excellent for exploration, but not always the best final form for production code. A useful rule of thumb is:
- use notebooks to explore, explain, and prototype,
- move stable logic into scripts or modules once it starts to grow.
Inside a Python file (as shown in the screenshot above), you should also be able to import common scientific packages:
import numpy
import pandas
import matplotlibIf all of that works, your environment is ready for the rest of Module 1.
These checks should succeed in the terminal of VSCode:
python --version
conda --version
jupyter lab --version- If VS Code runs the wrong interpreter, re-select it from the command palette.
- If a package import fails, check whether the correct environment is active.
- If a notebook kernel is missing, make sure Jupyter is installed in the same environment you selected in VS Code.
- If installation asks for admin rights unexpectedly, verify whether a user-level installation is possible before escalating.
In Powershell or Windows Terminal or VSCode Terminal, you may get the error File C:\Users\tom\Documents\WindowsPowerShell\profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
That error means Windows PowerShell's execution policy prevents running profile scripts (needed by Conda/MiniForge too). The recommended solution is to allow scripts for the current user only:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force
RemoteSigned here lets locally created scripts run, downloaded scripts must be signed.
Verify to confirm the policy for the relevant scope is RemoteSigned (or Bypass for Process):
Get-ExecutionPolicy -List
Once your tools are working, the next step is learning how Python code is structured: expressions, variables, types, functions, and simple programs.