You have two ways in which you can run the tutorial locally.
conda
environmentTo run the tutorial locally, you should first install conda (or mamba).
It is also suggested that you have a recent version of git
. Check out how to install git
on your operating system.
Go to the directory on your machine where you want to download the material and clone the repository:
git clone https://github.com/empa-scientific-it/python-tutorial
Alternatively, you can manually download a ZIP archive with the latest version of the material:
Extract the archive in a directory of your choice.
Enter the tutorial folder with
cd /path/to/python-tutorial
You should now create a new environment with conda
:
conda env create -f binder/environment.yml
Warning
If you are on Windows and using Command Prompt or the PowerShell, please make sure to adjust the paths in the commands above accordingly.
Then activate the environment with
conda activate python-tutorial
You can update the existing environment (that is, downloading the latest version of the packages) with:
conda env update -f binder/environment.yml
Finally, launch JupyterLab with
jupyter lab
Note
The following instructions are for Windows. With minor changes, the steps work on macOS or Linux as well.
Install Docker Desktop: First, you need to install Docker Desktop on your Windows machine. You can download it from the official Docker website: https://www.docker.com/products/docker-desktop.
Create a folder: Open File Explorer and create a new folder where you want to save the tutorial's materials. For example, you could create a folder called "python-tutorial" on your Desktop.
Open PowerShell: Once Docker Desktop is installed, open PowerShell on your Windows machine. You can do this by pressing the "Windows" key and typing "PowerShell" in the search bar.
Pull the Docker image: In PowerShell, run the following command to pull the "empascientificit/python-tutorial" Docker image:
docker pull ghcr.io/empa-scientific-it/python-tutorial:latest
docker run -p 8888:8888 --name python_tutorial -v /path/to/python-tutorial:/home/jovyan/work ghcr.io/empa-scientific-it/python-tutorial:latest jupyter lab --ip 0.0.0.0 --no-browser
Replace /path/to/python-tutorial
with the path to the folder you created in step 2, for example C:/Users/yourusername/Desktop/python-tutorial
.
Note
The above command will mirror the content of your local folder (e.g.,
C:/Users/yourusername/Desktop/python-tutorial
) to thework/
folder inside the container. In this way, every file or folder you copy or create intowork/
will be saved on your machine, and will remain there even if you stop Docker.
http://localhost:8888/lab
. You should see the Jupyter Notebook interface. Enter the token provided in the PowerShell console to access the notebook. Alternatively, you can directly click on the link that appears in the PowerShell after the container has started.You can now use the Jupyter in the Docker container to run the python-tutorial. When you're done, you can stop the container by pressing Ctrl+C
in the PowerShell console.
Note
If you want to restart the container, you can simply run the command
docker container start python_tutorial
.