Python setup & napari installation#
Tip
If you have any issues with installation, please feel free to write us a message on the napari zulip and we will try to help you get unstuck.
Note
Make sure you review the instructions below and verify that they are still correct before using them in your workshop.
Installing Python using conda#
In this tutorial, we will install Python via miniforge, a distribution of Python based in the conda package manager. If you already have anaconda, miniconda, or miniforge installed, those will work as well and you can skip to the next section.
In your web browser, navigate to the miniforge page.
Scroll down to the “Miniforge3” header of the “Downloads” section. Click the link to download the appropriate version for your operating system. Note that even if you have a new Apple computer with an M1 processor, you should download the OS X x86_64 version.
Windows:
Miniforge3-Windows-x86_64
Mac with Intel processor:
Miniforge3-MacOSX-x86_64
Mac with M1 (“Apple silicon”):
Miniforge3-MacOSX-x86_64
Linux with an Intel processor:
Miniforge3-Linux-x86_64
Once you have downloaded miniforge installer, run it to install Python.
Windows
Find the file you downloaded (
Miniforge3-Windows-x86_64.exe
) and double click to execute it. Follow the instructions to complete the installation.Once the installation has completed, you can verify it was correctly installed by searching for the “miniforge prompt” in your Start menu.
Mac OS
Open your Terminal (you can search for it in spotlight -
cmd
+space
)Navigate to the folder you downloaded the installer to. For example, if the file was downloaded to your Downloads folder, you would enter:
cd ~/Downloads
Execute the installer with the command below. You can use your arrow keys to scroll up and down to read it/agree to it.
bash Miniforge3-MacOSX-x86_64.sh -b
To verify that your installation worked, close your Terminal window and open a new one. You should see
(base)
to the left of your prompt.Finally, initialize miniforge with the command below. This makes sure that your terminal is set up correctly for your python installation.
conda init
Linux
Open your terminal application
Navigate to the folder you downloaded the installer to. For example, if the file was downloaded to your Downloads folder, you would enter:
cd ~/Downloads
Execute the installer with the command below. You can use your arrow keys to scroll up and down to read it/agree to it.
bash Miniforge3-Linux-x86_64.sh -b
To verify that your installation worked, close your Terminal window and open a new one. You should see
(base)
to the left of your prompt.Finally, initialize miniforge with the command below. This makes sure that your terminal is set up correctly for your python installation.
conda init
Setting up your environment#
Open your terminal.
Windows: Open the “miniforge prompt” from your start menu
Mac OS: Open Terminal (you can search for it in spotlight -
cmd
+space
)Linux: Open your terminal application
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
napari-tutorial
) and install Python 3.9 in it, enter the following command:conda create -n napari-tutorial python=3.9
Once the environment setup has finished, activate the environment:
conda activate napari-tutorial
If you successfully activated the environment, you should now see
(napari-tutorial)
to the left of your command prompt.Install the workshop dependencies with the commands below.
If you’re on an M1 Mac:
conda install -c conda-forge notebook napari python -m pip install cookiecutter magicgui python -m pip install stardist-napari
Other systems:
conda install -c conda-forge notebook python -m pip install cookiecutter magicgui "napari[all]" python -m pip install stardist-napari
If you are on a Mac, please install this one additional dependency.
conda install -c conda-forge python.app
Test that your notebook installation is working. We will be using notebooks for interactive analysis. Enter the command below and it should launch the
jupyter notebook
application in a web browser. Once you’ve confirmed it launches, close the web browser and pressctrl+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?
Sometimes, napari
installation can fail on an M1 Mac due to mismatching
dependencies on pip
.
If you get an error at step 4 above, or can’t launch napari
after
installation, you should try to delete your napari-tutorial
environment, and
follow the installation instructions below.
Delete your
napari-tutorial
environmentconda activate base conda env remove -n napari-tutorial
Create your environment and install
napari
fromconda-forge
conda create -y -n napari-tutorial python=3.9 napari
Then, after creation:
conda activate napari-tutorial conda install -c conda-forge notebook pip install cookiecutter magicgui pip install stardist-napari