Anaconda logo

The open-source Anaconda Individual Edition distribution is one of the easiest ways to perform data science projects. It already includes Python and the most important modules we need.

If you already have Anaconda on your machine, make sure that you use the latest version (in our course, we use Python 3.9 but Python 3.8 or 3.7 is also fine). In your terminal, type

python --version

to see which Python version you are using in your Anaconda base environment.

You may also uninstall your current Anaconda environment from your machine and install the latest version: here a guide of how to uninstall Anaconda.

If you aren't familiar with the terminal, read this introduction to the command-line interface.

During the first installation, Anaconda installed 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 terminal). If not, type:

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).

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).

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

conda create -n myenv python=3.9

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

conda activate myenv
conda list
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
conda list scikit-learn
conda install -c anaconda scikit-learn=1.0.2

There are several options how to install modules in a Anaconda environment.

Conda

conda is the official Anaconda module manager.

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 TensorFlow version 2.0 or higher), works out how to install a compatible set of dependencies, and shows a warning if this cannot be done.

The conda team, from Anaconda, Inc., packages a multitude of packages and provides them to all users free of charge in their default channel.

But what if a package you are looking for is not in the default channel? One option is to use conda-forge (see below).

Conda-forge

Conda-forge is a community-led collection of recipes, build infrastructure and distributions for the conda package manager.

Pip

Instead of conda, you can also use pip (the standard package installer for Python) to install packages.

Note that we will use pipin this environment to install packages (and not conda). Therefore, we install pip in this environment.

Let`s install some additional modules in our base environment.

Furthermore, 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).

conda analyses the current environment including everything currently installed, and, together with any version limitations specified (e.g. the user may wish to have TensorFlow version 2.0 or higher), works out how to install a compatible set of dependencies, and shows a warning if this cannot be done. Instead of conda, you can also use pip (the standard package installer for Python) to install packages.

Conda environments help manage dependencies and isolate projects. This is particularly useful when some packages require specific Python versions. Note that we will use pipin this environment to install packages (and not conda). Therefore, we install pip in this environment.

On Windows open the Start menu and open an Anaconda Command Prompt. On macOS or Linux open a terminal window.

We create an environment with a specific version of Python (3.9) and the TensorFlow package. We call the environment tf:

conda create -n tf python=3.9 pip

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

You can activate your environment as follows:

conda activate tf

You can install TensorFlow as follows (see documentation):

Step 1: upgrade pip:

pip install --upgrade pip

Step 2: install TensorFlow:

pip install tensorflow

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

✅ TensorFlow

If you'd like to learn more about TensorFlow, have a look at the following suggestion:

If you want to switch back to your Anaconda base environment, just use:

conda deactivate

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.

Copyright: Jan Kirenz (2021), kirenz.com, Creative Commons Attribution-NonCommercial 2.0 Generic (CC BY-NC 2.0) License