Setting up your python environment#
Installing python via mambaforge#
In this tutorial, we will install python via mambaforge, a distribution of anaconda python. However, if you already have anaconda, miniconda, mambaforge, or miniforge installed, those will work as well and you can skip to the next section.
To install python via mambaforge, follow the instructions here.
Setting up your environment#
Using conda instead of mamba?
The following assumes that you have installed python using Mambaforge as described above. If you are using a pre-existing installation of python via anaconda, miniconda, or miniforge, you can simply replace the mamba
commands with conda
.
Download the environment file. This contains all of the libraries required for the tutorial and we will use it to set up our conda environment. To download, right click and “Save as” this link. Take note of the path to where you downloaded the file.
Open your terminal.
Linux: Open your terminal application
Mac OS: Open Terminal (you can search for it in spotlight - cmd + space)
Windows: Open the “manbaforge prompt” or “miniforge prompt” from your start menu
We use an environment to encapsulate the python tools used for this workshop. This ensures that the requirements for this workshop do not interfere with your other python projects. To create the environment (named
em-napari
) from the environment file you downloaded in the first step, enter the following command. Replacepath/to/environment.yaml
with the path to theenvironment.yaml
file you downloaded in the first step. You can also drag and drop theenvironment.yaml
file into your terminal window to get the path.mamba env create -f path/to/environment.yaml
Once the environment setup has finished, activate the environment. If you successfully activated the environment, you should now see
(em-napari)
to the left of your command prompt.mamba activate em-napari
If you are on a Mac or linux, please install these additional dependencies.
mamba install -c conda-forge ocl-icd-system
mamba install -c conda-forge python.app ocl_icd_wrapper_apple
Test that your notebook installation is working. We will be using notebook for interactive analysis. Enter the command below and it should launch jupyter notebook book in a web browser. Once you’ve confirmed it launches, close the web browser and press ctrl+c in the terminal window to stop the notebook server.
jupyter notebook
Test your napari installation. Enter the command below and an empty napari viewer should open. You can close the window after it opens. Please note that it takes a bit of extra time to launch napari the first time.
napari
Errors launching?
If you receive an error when attempting to launch and/or install napari, you can ask for help on:
image.sc: forum for bioimage analysis questions
napari zulip: chat about napari