How the setup works
What each command of the Setup page does, where things end up, and how to remove them.
You can follow the Setup without reading this. Read it to understand your installation, or to repair it.
Packages and pip
- A package is code that someone else wrote and you import:
pandas,duckdb. A package manager downloads packages, with the other packages that they need, and installs them. - pip is the package manager of Python. It downloads from PyPI, the public repository of Python packages.
requirements.txtis the list of packages of the course, one per line, with at most a minimum version (pandas>=2.2). pip installs the newest versions that fit, so two students can end with slightly different ones.
python -m pip install -r S00_Setup/requirements.txt- This line installs every package of that list into the Python that runs it.
- Why
python -m pip: a computer can have several Pythons, each with its own pip.python -m pipis the pip of the Python that is active, so the packages go where your Jupyter will look for them.
Conda environments
An environment is a separate folder with its own Python and its own packages.
| Command | What it does |
|---|---|
conda create -n dma python=3.12 -y |
Creates an environment called dma, with its own Python 3.12 |
conda activate dma |
Makes this terminal use dma: python is now the Python of dma |
- Why a separate environment: the course packages stay out of
baseand out of the environments of your other courses, so nothing that worked before changes. - Remove it:
conda env remove -n dma.
uv
uv is one program that does both jobs: it installs Python and it manages the packages of a project folder.
| File or command | What it is |
|---|---|
pyproject.toml |
The list of packages of the course and the Python versions allowed (3.12 or 3.13) |
uv.lock |
The exact version of every package, the same for everyone |
uv sync |
Creates DMA/.venv with Python and exactly the packages of uv.lock |
uv run <command> |
Runs the command inside DMA/.venv. Nothing to activate |
- Where things live: the environment is the folder
DMA/.venv.uvalso keeps the downloads in a cache and its Pythons in its own folder, both in your user folder and outsideDMA.
uv cache diruv python dir- Remove it: delete the folder
DMA/.venv.uv synccreates it again.uv cache cleanempties the cache. To removeuvitself:uv python uninstall --allremoves the Pythons it installed, and the uv documentation shows how to delete the program. - Why we recommend it: with
uv.lock, your laptop, the lecturer’s computers and the department computer room run the same versions.
Kernels
- How Jupyter knows a kernel: by a kernelspec, a small folder with a file
kernel.jsonthat holds the name shown in the menu and the command that starts the language. - Where they live: inside the environment (
DMA/.venv/share/jupyter/kernels/, or the same path insidedma) or in your user folder. This command lists the ones your Jupyter sees, with their folders:
uv run jupyter kernelspec listjupyter kernelspec list- The Python kernel (
python3) comes from the packageipykernel, which is in the course list. - The R kernel comes from the R package
IRkernel. The script below installs it and registers it.
What install_r_kernel.py does
- Finds R: the path given with
--rscript, thenR_HOME, thePATH, and the usual folders of each system (on Windows, also the registry). - Installs the R packages of
S00_Setup/r_packages.txtthat are missing, into your personal R library. They come from CRAN; on Ubuntu and Debian, ready-made from Posit Package Manager. - Registers the kernel: it copies the kernelspec of
IRkernel, writes in it the full path of your R and of your R library, names it R (DMA) (internal nameir-dma), and installs it inside the environment of the Python that runs the script.
- Why inside the environment: only the Jupyter of the course sees R (DMA). Any other Jupyter on your computer stays as it was.
- Only the kernel, without the package list: add
--only-kernelto the command. - Remove the kernel (the R packages stay in your R library):
uv run jupyter kernelspec remove ir-dmajupyter kernelspec remove ir-dmaWhat the check notebooks check
| Notebook | What it does |
|---|---|
check_setup.ipynb |
Prints the Python version, the interpreter in use and the working directory |
| Imports every Python package of the course and prints its version | |
Builds a small table with pandas, draws a plot with matplotlib and runs an SQL query on it with duckdb |
|
Prints ALL OK if no package is missing |
|
check_setup_R.ipynb |
Prints the R version and the R library in use |
Checks that every package of r_packages.txt loads, and prints ALL OK |
The line Interpreter of the first notebook tells you which environment the kernel uses: it must be inside DMA/.venv or inside dma.