Installing Python packages#
This section contains instructions on how to install additional packages useful for scientific programming, such as
IPython for development
Matplotlib for plotting
NumPy for scientific computing
Prerequisites#
You have a working Python installation based on mamba (Section 01) or conda.
You understand the differences between the Windows prompt, the miniforge prompt, and the Python interpreter.
Warning
If you still have doubts about any of these terms, do not hesitate to revisit the installation instructions in Section 01.
Context: the conda (base) environment#
When you open the miniforge prompt (a terminal in Linux/macOS), 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 mamba, which is a package management system for Python. It gives you access to a very large number of Python packages for free (the only thing you need is an internet connection to connect to the package servers).
More details about Mamba
You were asked to install miniforge for two main reasons:
Miniforge is giving you access to the packages available from conda-forge, which is an up-to-date repository for Python packages.
Miniforge includes a
mambainstaller.mambais a “drop-in” replacement forconda, and is significantly faster.
You will recognize that you are using conda thanks to the following signs:
When opening the miniforge prompt or terminal, a
(base)text appears in front of the current path. For the user 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.exethat came with the conda installation.
You can ask for the location of a specific prompt command with the command where (which in Linux). For Jane, the miniforge prompt gives the following indications about the location of python:
(base) C:\Users\Jane> where python
C:\Users\Jane\mambaforge\python.exe
C:\Users\Jane\AppData\Local\Microsoft\WindowsApps\python.exe
(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.
Install IPython and JupyterLab in the (base) environment#
IPython and Jupyter are fundamental tools of a scientific Python installation. If you have worked with Python before, you are probably familiar with Jupyter Notebooks. To install them, type the following from the miniforge prompt (terminal on Linux/macOS)
mamba install ipython jupyterlab
This will install IPython and JupyterLab at the same time. To check if it worked, type
ipython
This should display something like
Python 3.14.7 | packaged by conda-forge | (main, Sep 2 2026, 21:08:32) [GCC 15.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.17.1 -- An enhanced Interactive Python. Type '?' for help.
Tip: Use `ipython --help-all | less` to view all the IPython configuration options.
In [1]:
The only visual difference between the ipython and python interpreters is that >>> has been replaced by In [1]:. More on this later.
You can now run your script my_python_script.py from within the IPython interpreter:
%run my_python_script
Exit ipython with exit or quit.
Exercise 1
Open a miniforge prompt/terminal and ask Windows/Linux where to find your current Python installation. Compare yours with Jane’s.
What about the location of ipython? And of jupyter-lab?
Managing environments#
These instructions are useful for later in the class when you will be asked to install more packages and maybe for other classes for which you may have to install packages.
Create an environment called “scipro”#
(base) is the name of the base (default) environment for conda. Installing further packages in (base) is fine, but it is not recommended. It is recommended to keep (base) as simple as possible, with few or no packages installed, and use named environments for further usages.
First, open the miniforge prompt (terminal) and type the following command
mamba create -n scipro --clone base
If asked to confirm, type “yes”.
What did we just do? We created a new conda environment called scipro (this is the purpose of the option -n) which clones all packages available in base with the option --clone base (this last part is optional: if you omit it, your new environment will be completely empty and you will have to reinstall IPython in your environment scipro to be able to use it).
You can now activate your new environment with mamba activate scipro.
Exercise 2
Activate the new environment. What changed in comparison to (base)? Now ask the prompt again about where to find the commands ipython and jupyter-lab. Can you see the difference to base?
Conda environments are a very simple and elegant way to manage different installations of Python packages. They allow to clearly separate different installations and, more importantly, conda environments allow us to make mistakes.
Since “environments” are nothing else than folders on your computer, they allow setups such as:
(base): python v3.14, JupyterLab, IPython(scipro): same as(base)+ NumPy, SciPy, Matplotlib, etc.(test): python 3.10(complex): same as(base)+ NumPy “beta version” + complicated packageetc.
You can switch between environments with mamba activate env_name and leave the current environment with mamba deactivate.
Important
You can see which environment is active by the (base) or (scipro) indicator in front of the prompt. In the active environment, ALL mamba commands refer to this specific environment.
For example, to list the packages available in scipro, you need to activate it first (mamba activate scipro) and then list the packages with mamba list.
To open IPython and have access to the packages installed in scipro, activate the environment first and then start ipython.
When one of your environments becomes “broken” or obsolete, you can simply delete it with mamba remove -n ENVNAME --all. This will delete the corresponding folder and all packages in it. Creating, activating, and deleting environments is super easy, and this is why we recommend their use.
Mamba/conda cheat sheet:
mamba create -n scipro --clone base: create an environment called “scipro” with the same packages in it asbasemamba create -n scipro: same as above, but emptymamba activate scipro: activate environmentscipromamba deactivate: leave the current environmentmamba info --envs: get a list of all environmentsmamba list: list the currently installed packages in a specific environmentmamba remove -n scipro --all: delete the environmentsciproand all packages in it.
Visit the conda documentation for more commands (just replace all “conda” commands with “mamba”).
Installing additional Python packages in the active environment#
In the course of your studies, you will likely need to install many Python packages, for example Xarray for gridded data analysis or MetPy for meteorology.
Almost always, the install procedure will be:
open the miniforge prompt/terminal
(optional but recommended) activate the environment where you want to install the package
install the package with
mamba install
For now, 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 scipro 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#