The open-source project Miniforge is one of the easiest ways to get started with data science projects. It is a small, bootstrap version of the data science platform Anaconda (like Minconda) that includes only Python, the open source package management system conda and a small number of other useful packages.

Windows

If you have Windows:

C:\Users\foo\miniforge3\Scripts\activate

macOS

If you have macOS:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install miniforge
conda init zsh

During the first installation, Miniforge installed the so called base environment including Python and some useful Python modules (modules are like apps on your smartphone). Let`s take a look at this environment:

Usually, the base environment is already activated (and you can see the word base in your terminal. If not, try: conda activate base)

conda list

You should see a list of modules with their name, version, build (more detaild information about the package) and channel (from which the packages were installed).

The package manager conda makes it easy to manage multiple "environments" (like the base environment) that can be maintained and run separately without interference from each other (in so called virtual environments).

Conda environments help manage dependencies and isolate projects. This is particularly useful when some packages require specific module versions.

Environment for scikit-learn

In this example we will install the module scikit-learn with conda.

conda create -n sklearn-env -c conda-forge scikit-learn

When conda asks you to proceed (proceed ([y]/n)?), type y.

conda activate sklearn-env
conda list
conda deactivate

If you want to update a specific environment (this will update all packages in the selected environment to the latest version but will not update Python), use this command: conda update --all

Make sure to activate the right environment first. In our example, we use the sklearn-env environment so we first activate it

conda activate sklearn-env
conda update --all
conda update scikit-learn

There are two options of how to install modules in an environment: with conda or pip. Note however, that ideally you should always only use one of the two methods in one environment.

Conda-forge

As a first option, you should always try to download a package from conda-forge. Here is a list of conda-forge packages.

conda install package-name

As an example, let's install some additional modules in our sklearn-env environment:

conda activate sklearn-env
conda install pandas

Pip

Instead of conda, you can also use pip (the standard package installer for Python) to install packages. Use this option if the package you want to install isn't available in conda.

Note that you should always create a new environment and only use pip to install new modules in this environment.

pip install package-name

Congratulations! You have completed the tutorial and learned how to:

✅ install Miniforge
✅ create virtual environments
✅ install modules using conda

Jan Kirenz

Thank you for participating in this tutorial. If you found any issues along the way I'd appreciate it if you'd raise them by clicking the Report a mistake button at the bottom left of this site.

Jan Kirenz (2022) | kirenz.com | Made with Codelabs