Setup
Before you start, make sure this is set up.
Jupyter Notebook opens from your DMA folder and runs the course notebooks with two kernels: Python and R (DMA). You know it works when the two check notebooks print ALL OK (step 5).
New to notebooks or kernels? Read Notebooks, kernels and editors first: five minutes.
| Your starting point | Your path |
|---|---|
| I have Anaconda, or the Python from Programming | Steps 1 to 3, then tab I have Anaconda in step 4 |
| I want a clean installation | Steps 1 to 3, then tab Clean installation (recommended) |
| I cannot install today | Work in Colab and come back here later |
1. Get the course folder
Extract it in your user folder, so that you get C:\Users\<you>\DMA (Windows) or ~/DMA (macOS, Linux).
- What the folder is for: the notebooks and the data of every session live in
DMA, and the notebooks read the data with relative paths such asdata/wdi_panel.csv. With the same folder, the same code runs on every computer. - What the zip contains: the list of packages of the course (
pyproject.toml,uv.lock,requirements.txt), a script that connects R to Jupyter, and two notebooks that check your installation (inS00_Setup). - Windows: right-click the zip, Extract All, and set the destination to your user folder,
C:\Users\<you>. - macOS: double-click the zip in Downloads (Safari may have done it already) and drag the folder
DMAinto your home folder (Finder, Go, Home). - Linux: in a terminal,
unzip ~/Downloads/DMA_setup.zip -d ~. - Keep it out of Desktop and Documents if OneDrive or iCloud synchronise them.
2. Install R
Install R from https://cran.r-project.org with the default options. On macOS, choose the installer for your processor (Apple silicon or Intel).
3. Open a terminal in DMA
Every command below runs in this terminal.
Windows 11: in File Explorer, right-click inside DMA, then Open in Terminal. Windows 10: Shift + right-click inside DMA, then Open PowerShell window here.
With Anaconda, open Anaconda Prompt and run:
cd /d %USERPROFILE%\DMAIn Finder, right-click the DMA folder, then Services, then New Terminal at Folder.
Right-click inside DMA, then Open in Terminal.
Check: dir (Windows) or ls (macOS, Linux) lists pyproject.toml.
4. Install the packages and the R kernel
Choose one tab. The first two end with the same packages and kernels. What each command does: How the setup works.
You keep your Anaconda. These lines create an environment dma for the course and leave base and your other environments as they are. Run them one at a time. If conda create stops with a Terms of Service message, run the conda tos accept lines that it prints and repeat the command.
conda create -n dma python=3.12 -yconda activate dmapython -m pip install -r S00_Setup/requirements.txtpython S00_Setup/install_r_kernel.pypython -m notebookThe third line installs the Python packages, the fourth the R packages and the kernel R (DMA), the last one opens Jupyter.
With another Python 3.12 or 3.13 that you already use, run only the three python lines.
uv is a small program that installs Python and the course packages inside DMA/.venv, with the exact versions that we tested. It leaves any other Python on your computer untouched.
a. Install uv (once).
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"curl -LsSf https://astral.sh/uv/install.sh | shcurl -LsSf https://astral.sh/uv/install.sh | shThen close the terminal and open a new one in DMA, so that it finds uv.
b. Install Python and the packages (a few minutes, about 1 GB).
uv syncc. Install the R packages and the kernel R (DMA) (a few minutes the first time).
uv run python S00_Setup/install_r_kernel.pyd. Open Jupyter.
uv run jupyter notebookUse Colab: it runs the notebooks in your browser with a Google account. Come back to this page when you can, because your own installation is faster and keeps your files.
5. Check
- In Jupyter, open
S00_Setup/check_setup.ipynb. - Menu Kernel, then Restart Kernel and Run All Cells. The last line must print
ALL OK. - Open
S00_Setup/check_setup_R.ipynb, choose Kernel, then Change kernel, then R (DMA), and run all cells again. The last line must printALL OK.
Every day
Open a terminal in DMA (step 3) and start Jupyter.
conda activate dmapython -m notebookuv run jupyter notebookFor JupyterLab, use python -m jupyterlab or uv run jupyter lab.
Organise your course folder
Everything of the course goes inside DMA, one folder per session. The notebooks read their data with relative paths, so the folder names must be these.
DMA/
├── pyproject.toml the packages of the course
├── uv.lock
├── S00_Setup/ from DMA_setup.zip
│ ├── check_setup.ipynb
│ ├── check_setup_R.ipynb
│ └── ...
├── S01_pandas_I/ from the zip of session 1
│ ├── S01_pandas_I.ipynb
│ └── data/
│ └── wdi_panel.csv
├── S02_.../ each later session, from its zip
│ ├── S02_....ipynb
│ └── data/
└── data/ data shared by several sessions
└── ...
For each session: download its zip from Sessions, extract it in your user folder as you did with DMA_setup.zip (every zip carries DMA/..., so its files land inside DMA), and open the notebook from Jupyter. With uv you will also see DMA/.venv, where the packages are installed.
If something fails
| What you see | What to do |
|---|---|
uv is not recognized, or command not found |
Close the terminal and open a new one in DMA |
No pyproject.toml found |
The terminal is in the wrong folder: go to the inner DMA |
No module named duckdb, or no kernel R (DMA) |
Jupyter was started from elsewhere (Navigator, Start menu): close it and start it from DMA |
R was not found |
Install R (step 2), or give its path as below |
| Any line of the Anaconda tab fails | Use the clean installation: it is independent of what you have |
R installed and still missing: add its path, with the version that you installed.
uv run python S00_Setup/install_r_kernel.py --rscript "C:\Program Files\R\R-4.x.y\bin\Rscript.exe"Still failing: bring the error message to class or to office hours.
What pip, conda, uv and the R script do, and how to remove them: How the setup works.
What notebooks, kernels and editors are, and other programs and languages (VS Code, RStudio, Stata, MATLAB, Julia): Notebooks, kernels and editors.