Installing python packages#

This chapter contains instructions about how to install additional packages useful for scientific programming


  • you have a working python installation based on mambaforge (Week 01)

  • you have installed jupyterlab (Week 02)

  • you understood the differences between the windows prompt, the miniforge prompt, the python interpreter, the ipython interpreter, and jupyterlab.


If you still have doubts about all these terms, don’t hesitate to revisit the installation instructions in weeks 01 and 02, as well as the video in week 03

Context: conda environments#

When you open the miniforge prompt, you are opening a windows prompt with new tools available: for one, python is installed and can be run. Similarly, conda and mamba commands are only available from the miniforge prompt, and not from the standard prompt. This is possible thanks to conda, which is a package management system for python. Conda gives you access to a very large number of python packages for free (the only think you’ll need is an internet connection, to connect to the package servers).

You will recognize that you are using conda thanks to the following indices:

  • when opening the miniforge prompt, a (base) text appears in front of the current path. For Jane, a typical miniforge prompt looks like: (base) C:\Users\Jane>

  • when Jane asks her computer where to find python, conda is indicating the python.exe that came with the conda installation.

You can ask for the location of a specific prompt command with the command where. For Jane, the miniforge prompt gives the following indications about the location of python:

(base) C:\Users\Jane> where python 

(base) C:\Users\Jane> 

The first python.exe on the list is the one that will be used if you type python in the prompt. This is precisely why conda is useful: it clearly separates your python installation from all other contents on your computer.

Exercise 1

Open a miniforge prompt and ask windows where to find your current python installation. Compare yours with Jane’s. What about the location of ipython? And of jupyter-lab?

Required: installing additional python packages#

In the course of your studies, you will be lead to install many (many) python packages, for example xarray for gridded data analysis or MetPy for meteorology.

Almost always, the install procedure will be:

  1. open the miniforge prompt

  2. (optional but recommended) activate the environment where you want to install the package

  3. install the package with mamba install

For now, I ask you to install the following python packages:

  • numpy, the fundamental package for scientific computing with Python

  • scipy, fundamental algorithms for scientific computing in Python

  • matplotlib, data visualization with Python

To install these, activate the inpro environment (recommended) or use base, and type:

mamba install numpy scipy matplotlib

Answer “yes” to confirm the installation. Note that mamba will install several additional packages. These automatically installed packages are called “dependencies”: they are required for the other packages to function properly.

To test if the installation worked properly, open an ipython interpreter and type:

In [1]: import numpy as np
In [2]: np.arange(1, 11, 2)

The output should be:

Out[2]: array([1, 3, 5, 7, 9])

Congratulations! You are ready for the rest of the lecture.

Learning checklist#