Installation#
Conda is a powerful package manager and environment manager.
Ref: Getting started with mamba
Install Anamamba (large) or Minimamba (small) or Miniforge (best)#
wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh
bash Mambaforge-Linux-x86_64.sh -b
Open a terminal (Linux/MacOSX) or a Anamamba prompt (Windows)#
Verify that mamba is installed and running on your system by typing:
%%bash
~/miniforge3/bin/mamba init
Close the terminal and open a new one.
Conda displays the number of the version that you have installed.
If you get an error message, make sure you closed and re-opened the terminal window after installing, or do it now.
To update mamba to the current version. Type the following:
mamba update -y mamba -n base
Managing channels#
Conda channels are the locations where packages are stored. We use the conda-forge, a good community-led collection of recipes for mamba. If you installed Miniforge or Mambaforge you already have a mamba specific to conda-forge.
mamba config --add channels conda-forge
mamba config --set channel_priority strict
Strict channel priority speed up mamba operations and also reduce package incompatibility problems.
Managing environments#
Conda/Mamba allows you to create separate environments containing files, packages, and their dependencies that will not interact with other environments.
When you begin using mamba, you already have a default environment named
base
. You don’t want to put programs into your base environment, though.
Create separate environments to keep your programs isolated from each other.
Create a new environment and install a package in it.#
We will name the environment big-data
and install the version 3.10 of python
. At the Anamamba Prompt or in your terminal window, type the following:
mamba create -y -n big-data python=3.10
To use, or “activate” the new environment, type the following:#
mamba activate big-data
Now that you are in your big-data
environment, any mamba commands you type will go to that environment until you deactivate it.
Verify which version of Python is in your current environment:
python --version
To see a list of all your environments, type:#
%%bash
mamba info --envs
The active environment is the one with an asterisk (*).
Change your current environment back to the default (base):#
mamba activate
Managing packages#
Check to see if a package you have not installed named “jupyter” is available from the Anamamba repository (must be connected to the Internet):
%%bash
mamba search jupyter
Conda/Mamba displays a list of all packages with that name on conda-forge repository, so we know it is available.
Install this package into the base environment:
mamba activate
mamba install -y jupyter
Update a new mamba environment from file#
It is possible to create an environment from a file environment.yml
.
This file contains the packages list.
name: exercices
channels:
- conda-forge
dependencies:
- python=3.10
- lorem
- matplotlib
- seaborn
- pandas
mamba env update -f environment.yml
Activating the mamba environment will change your shell’s prompt to show what virtual environment you’re using, and modify the environment so that running python will get you that particular version and installation of Python.
$ mamba activate py36 (big-data) $ python Python 3.6.2 (default, Jul 17 2017, 16:44:45) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> quit()
You must do this everytime you open a new terminal
Install the kernel for jupyter#
mamba activate exercices
mamba install ipykernel
python -m ipykernel install --user --name exercices
With this command you create the exercices
kernel with python and all course dependencies.
The cell above will give you the path to the python that runs in this notebook.
To display which python is running
import sys
print(f"{sys.executable}")