The tutorials can be run in two ways:
Online, with no installation: click the
icon at the top right of a tutorial page to launch it on Binder. Starting can take a few minutes, and your changes are lost when you close the page.On your computer, by following the instructions below. This is faster and lets you keep your changes.
You need two things: pixi, a small program that installs Python and all the required packages for you, and the tutorial folder, which tells pixi exactly what to install. If you already have another Python installation (for example Anaconda), it will not interfere. Use the terminal as described below rather than the Anaconda Prompt.
Part 1: Installation (once)¶
Step 1: Install pixi¶
Open the Start menu, type terminal and open Terminal. This is a window into which you type commands.
Copy the line below, paste it into the terminal, and press Enter:
powershell -ExecutionPolicy ByPass -c "irm -useb https://pixi.sh/install.ps1 | iex"Then close the terminal and open a new one. Check that pixi is installed and working by typing:
pixi --versionPress Cmd+Space, type terminal and press Enter. This is a window into which you type commands.
Copy the line below, paste it into the terminal, and press Enter:
curl -fsSL https://pixi.sh/install.sh | shThen close the terminal and open a new one. Check that pixi is installed and working by typing:
pixi --versionIt should print a version number. See the pixi documentation if you run into problems.
Step 2: Download the notebooks folder¶
The notebooks are in the notebooks folder of the repository. GitHub cannot download a single folder as a ZIP file, so use the download-directory tool, which creates a ZIP file of the folder. Unzip it and move the resulting notebooks folder somewhere you will keep your work, for example Documents.
Step 3: Install the packages¶
Open a terminal from the notebooks folder (the folder that contains pixi.toml) and type:
pixi installThe first time, pixi downloads Python and all the packages. This can take several minutes and may look like nothing is happening. Wait until the command finishes. Later, starting is instant.
Part 2: Running the tutorials (every time)¶
Open a terminal in the
notebooksfolder (the folder that containspixi.toml).Start JupyterLab:
pixi run editorJupyterLab opens in your browser. Double-click a tutorial in the file browser on the left, for example
Tuto_floris.ipynb.Run code cells by pressing Shift+Enter or click the ▶ button in the toolbar. Cells should be run from top to bottom.
When you are done, save your work, close the browser tab, and press Ctrl+C in the terminal.
Working with a notebook¶
A notebook is made of cells, which contain either text or code.
Click a code cell and press Shift+Enter to run it and move to the next one. Alternatively, click the ▶ button in the toolbar.
Run the cells in order from the top. Later cells use variables defined in earlier ones.
While a cell runs,
[*]appears next to it. When it is finished, a number appears.Sliders and other widgets become active after the cell that creates them has been run.
You can edit any code cell and run it again to see the effect of your change.
If something goes wrong, use Kernel → Restart Kernel and Run All Cells to start again from a clean state.
Troubleshooting¶
| Problem | Solution |
|---|---|
pixi is not recognized / command not found | You did not open a fresh terminal after Step 1. Close the terminal and open a new one. |
pixi says it cannot find a pixi.toml or workspace | You are in the wrong folder. Open the terminal in the folder that directly contains pixi.toml (see Step 2). |
A tutorial shows ModuleNotFoundError | You started JupyterLab in another way. Close it and start it with pixi run editor from the notebooks folder. |
Acknowledgments¶
This page is adapted from the Installing Python appendix of the TU Delft course Modelling energy systems by Stefan Pfenninger and contributors.