Anaconda is a software-company which offers various tools to perform data science tasks on a single machine. Their popular open-source Anaconda Individual Edition distribution includes
Note that Anaconda is quite large -the base install requires around 2GB- and we usually only use a small fraction of the preinstalled packages. Therefore, we will install the lightweight version of Anaconda, called Miniconda.
Miniconda is a free minimal installer for conda. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages.
You can skip this section if you don't already have Anaconda installed on your machine.
Open your terminal (learn how to open your terminal)
Anaconda is usually located in your home directory inside a folder called "opt". You can remove your entire Anaconda directory by typing the following command in your terminal:
rm -rf ~/opt/anaconda3
Graphical Installer
and install the software: Miniconda3 macOS Intel x86 64-bit pkgcd
into the directory where the file is located.sh ./Miniconda3-py310_23.1.0-1-MacOSX-arm64.sh
yes
to install the software.During the installation process, Miniconda created the so called base
environment. Let`s take a look at this environment:
Usually, the base
environment is already activated (and you can see the word base
in your shell).
Update your version of conda by running:
conda update -n base -c defaults conda
When conda asks you to proceed (proceed ([y]/n)?
), type y
.
The conda team, from Anaconda, Inc., provides various packages to all users free of charge in their defaults channel. However, to get more up-to-date modules, it's better to use the popular community-led alternative conda-forge.
Type this in your shell to add the conda-forge channel to conda:
conda config --add channels conda-forge
Then make conda-forge the priority channel:
conda config --set channel_priority strict
This ensures that conda will always try to install packages from the conda-forge channel first instead of other channels.
In the next step, we install some Python module with conda.
Anaconda's package manager conda
makes it easy to manage multiple data environments that can be maintained and run separately without interference from each other in so called virtual environments. A virtual environment in Python is a separate and isolated environment where you can install packages and dependencies without affecting other Python installations or the system's environment.
Installing Python modules in a virtual environment is recommended for several reasons:
If you install a new module with conda
, it analyses the current environment including everything currently installed, and, together with any version limitations specified (e.g. the user may wish to have a package in version 2.0 or higher), works out how to install a compatible set of dependencies, and shows a warning if this cannot be done.
You can take a look at all available packages on this website: https://anaconda.org/.
ds
(short for data science)conda create --name ds python=3.10 pandas scikit-learn altair vega vega_datasets
When conda asks you to proceed (proceed ([y]/n)?
), type y
.
conda activate ds
You are now inside your virtual environment ds (you should notice that base is replaced by ds in your shell)
ds
environment: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).
base
environment simply type:conda deactivate
If you want to update a specific Anaconda 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 base environment so we don't have to activate it
conda update --all
conda update scikit-learn
scikit-learn
in version 1.2.1 or higher:conda list scikit-learn
conda install -c anaconda scikit-learn=1.2.1
Congratulations! You have completed the tutorial and learned how to:
✅ install Miniconda
✅ use conda-forge
✅ create a virtual environment
✅ install modules
✅ update modules
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.
Copyright: Jan Kirenz (2023), kirenz.com, Creative Commons Attribution-NonCommercial 2.0 Generic (CC BY-NC 2.0) License