Anaconda is an open-source package manager, environment manager, and distribution of the Python and R programming languages.
This tutorial will guide you through installing the Python 3 version of Anaconda on an Ubuntu 20.04 server. For a more detailed version of this tutorial, with more thorough explanations of each step, please refer to How To Install the Anaconda Python Distribution on Ubuntu 20.04.
From a web browser, find the latest version of Anaconda for Python 3 at the Anaconda Downloads page:
https://www.anaconda.com/distribution/
At the time of writing, the latest version is 2020.02, but you should use a later stable version if it is available.
Change to the /tmp
directory on your Ubuntu 20.04 server as a sudo non-root user.
- cd /tmp
Use curl
to download the link that you copied from the Anaconda website. We’ll output this to a file called anaconda.sh
for quicker use.
- curl https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh --output anaconda.sh
We can now verify the data integrity of the installer with cryptographic hash verification through the SHA-256 checksum and the script we named anaconda.sh
.
- sha256sum anaconda.sh
Output2b9f088b2022edb474915d9f69a803d6449d5fdb4c303041f60ac4aefcc208bb anaconda.sh
You should check the output against the hashes available at the Anaconda with Python 3 on 64-bit Linux page for your appropriate Anaconda version.
- bash anaconda.sh
You’ll receive the following output to review the license agreement by pressing ENTER
until you reach the end.
Output
Welcome to Anaconda3 2020.02
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
When you get to the end of the license, type yes
as long as you agree to the license to complete installation.
Choose the location of your installation or press ENTER
to accept the default location.
OutputAnaconda3 will now be installed into this location:
/home/sammy/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/sammy/anaconda3] >>>
At this point, the installation process will continue. Note that it may take some time.
Once installation is complete, you’ll receive the following output:
Output...
installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>>
Type yes
so that you can initialize Anaconda3. You’ll receive some output that states changes made in various directories along with a thank you for installing Anaconda.
You can now activate the installation by sourcing the ~/.bashrc
file:
- source ~/.bashrc
Once you have done that, you’ll be placed into the default base
programming environment.
Use the conda
command to test the installation and activation:
- conda list
You’ll receive output of all the packages you have available through the Anaconda installation:
It’s best practice to create new environments for each of your projects. To create a Python 3 environment called my_env
the syntax is as follows:
- conda create --name my_env python=3
Press y
to verify setup.
You can activate your new environment by typing the following:
- conda activate my_env
With your environment activated, your command prompt prefix will reflect that you are no longer in the base
environment, but in the new one that you just created.
-
When you’re ready to deactivate your Anaconda environment, you can do so by typing:
- conda deactivate
Here are links to more detailed tutorials that are related to this guide:
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!