How To Install the Anaconda Python Distribution on Ubuntu 20.04 - MS TV Life.COM

How To Install the Anaconda Python Distribution on Ubuntu 20.04

How To Install the Anaconda Python Distribution on Ubuntu 20.04

We hope this post helped you to find out  How To Install the Anaconda Python Distribution on Ubuntu 20.04

Introduction

Anaconda is an open-source bundle supervisor, setting supervisor, and distribution of the Python and R programming languages. It’s generally used for information science, machine studying, large-scale information processing, scientific computing, and predictive analytics.

Providing a set of over 1,000 information science packages, Anaconda is accessible in each free and paid enterprise variations. The Anaconda distribution ships with the conda command-line utility. You possibly can study extra about Anaconda and conda by studying the official Anaconda Documentation.

This tutorial will information you thru putting in the Python Three model of Anaconda on an Ubuntu 20.04 server.

Conditions

Earlier than you start with this information, you must have a non-root consumer with sudo privileges arrange in your server.

You possibly can obtain this prerequisite by finishing our Ubuntu 20.04 preliminary server setup information.

Installing in Anaconda

One of the best ways to put in Anaconda is to obtain the most recent Anaconda installer bash script, confirm it, after which run it.

Discover the most recent model of Anaconda for Python Three on the Anaconda Downloads page. On the time of writing, the most recent model is 2020.02, however you must use a later secure model whether it is out there.

Subsequent, change to the /tmp listing in your server. It is a good listing to obtain ephemeral objects, just like the Anaconda bash script, which we received’t want after working it.

cd /tmp

Use curl to obtain the hyperlink that you simply copied from the Anaconda web site. We’ll output this to a file referred to as anaconda.sh for faster use.

curl https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh --output anaconda.sh

We will now confirm the info integrity of the installer with cryptographic hash verification by way of the SHA-256 checksum. We’ll use the sha256sum command together with the filename of the script:

sha256sum anaconda.sh

You’ll obtain output that appears just like this:

Output

2b9f088b2022edb474915d9f69a803d6449d5fdb4c303041f60ac4aefcc208bb  anaconda.sh

It’s best to examine the output towards the hashes out there on the Anaconda with Python 3 on 64-bit Linux page in your acceptable Anaconda model. So long as your output matches the hash displayed within the sha2561 row, you’re good to go.

Now we will run the script:

bash anaconda.sh

You’ll obtain the next output:

Output


Welcome to Anaconda3 2020.02

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>  

Press ENTER to proceed after which press ENTER to learn by way of the license. When you’re executed studying the license, you’ll be prompted to approve the license phrases:

Output

Do you approve the license terms? [yes|no]

As long as you agree, type yes.

At this level, you’ll be prompted to decide on the situation of the set up. You possibly can press ENTER to just accept the default location, or specify a special location to switch it.

Output

Anaconda3 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] >>> 

The installation process will continue. Note that it may take some time.

Once installation is complete, you’ll receive the following output:

Output

...
Preparing transaction: done
Executing transaction: done
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. One of the lines you receive will thank you for installing Anaconda.

Output

...
Thank you for installing Anaconda3!
...

Now you can activate the set up by sourcing the ~/.bashrc file:

source ~/.bashrc

After getting executed that, you’ll be positioned into the default base programming setting of Anaconda, and your command immediate will change to be the next:

(base) sammy@ubuntu:~$

Though Anaconda ships with this default base programming setting, you must create separate environments in your applications and to maintain them remoted from one another.

You possibly can additional confirm your set up by making use of the conda command, for instance with checklist:

(base) sammy@ubuntu:~$   conda list

You’ll obtain output of all of the packages you may have out there by way of the Anaconda set up:

Output

# packages in environment at /home/sammy/anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py37_0  
_libgcc_mutex             0.1                        main  
alabaster                 0.7.12                   py37_0  
anaconda                  2020.02                  py37_0  
...

Now that Anaconda is installed, we can go on to setting up Anaconda environments.

Setting Up Anaconda Environments

Anaconda digital environments help you preserve tasks organized by Python variations and packages wanted. For every Anaconda setting you arrange, you’ll be able to specify which model of Python to make use of and may preserve your entire associated programming information collectively inside that listing.

First, we will examine to see which variations of Python can be found for us to make use of:

(base) sammy@ubuntu:~$ conda search "^python$"

You’ll obtain output with the totally different variations of Python which you can goal, together with each Python Three and Python 2 variations. Since we’re utilizing the Anaconda with Python Three on this tutorial, you’ll have entry solely to the Python Three variations of packages.

Let’s create an setting utilizing the newest model of Python 3. We will obtain this by assigning model Three to the python argument. We’ll name the setting my_env, however you’ll doubtless wish to use a extra descriptive identify in your setting particularly if you’re utilizing environments to entry multiple model of Python.

(base) sammy@ubuntu:~$  conda create --name my_env python=3

We’ll obtain output with details about what’s downloaded and which packages will likely be put in, after which be prompted to proceed with y or n. So long as you agree, sort y.

The conda utility will now fetch the packages for the setting and allow you to know when it’s full.

You possibly can activate your new setting by typing the next:

(base) sammy@ubuntu:~$ conda activate my_env

Along with your setting activated, your command immediate prefix will replicate that you’re not within the base setting, however within the new one that you simply simply created.

(my_env) sammy@ubuntu:~$

Inside the setting, you’ll be able to confirm that you simply’re utilizing the model of Python that you simply had meant to make use of:

(my_env) sammy@ubuntu:~$  python --version

Output

Python 3.8.2

When you’re ready to deactivate your Anaconda environment, you can do so by typing:

(my_env) sammy@ubuntu:~$  conda deactivate

Note that you can replace the word source with . to achieve the same results.

To target a more specific version of Python, you can pass a specific version to the python argument, like 3.5, for example:

(base) sammy@ubuntu:~$  conda create -n my_env35 python=3.5

You can inspect all of the environments you have set up with this command:

(base) sammy@ubuntu:~$ conda info --envs

Output

# conda environments:
#
base                  *  /home/sammy/anaconda3
my_env                   /home/sammy/anaconda3/envs/my_env
my_env35                 /home/sammy/anaconda3/envs/my_env35

The asterisk indicates the current active environment.

Each environment you create with conda create will come with several default packages:

  • _libgcc_mutex
  • ca-certificates
  • certifi
  • libedit
  • libffi
  • libgcc-ng
  • libstdcxx-ng
  • ncurses
  • openssl
  • pip
  • python
  • readline
  • setuptools
  • sqlite
  • tk
  • wheel
  • xz
  • zlib

You can add additional packages, such as numpy for example, with the following command:

conda install --name my_env35 numpy

If you know you would like a numpy environment upon creation, you can target it in your conda create command:

conda create --name my_env python=3 numpy

If you are no longer working on a specific project and have no further need for the associated environment, you can remove it. To do so, type the following:

conda remove --name my_env35 --all

Now, when you type the conda info --envs command, the environment that you removed will no longer be listed.

Updating Anaconda

It’s best to often be sure that Anaconda is up-to-date so that you’re working with all the most recent bundle releases.

To do that, you must first replace the conda utility:

conda update conda

When prompted to take action, sort y to proceed with the replace.

As soon as the replace of conda is full, you’ll be able to replace the Anaconda distribution:

conda update anaconda

Once more, when prompted to take action, sort y to proceed.

This may guarantee that you’re utilizing the most recent releases of conda and Anaconda.

Uninstalling Anaconda

In case you are not utilizing Anaconda and discover that it’s good to uninstall it, you must begin with the anaconda-clean module, which can take away configuration information for while you uninstall Anaconda.

conda install anaconda-clean

Type y when prompted to do so.

Once it is installed, you can run the following command. You will be prompted to answer y before deleting each one. If you would prefer not to be prompted, add --yes to the end of your command:

anaconda-clean

This will also create a backup folder called .anaconda_backup in your home directory:

Output

Backup directory: /home/sammy/.anaconda_backup/2020-05-06T024432

You can now remove your entire Anaconda directory by entering the following command:

rm -rf ~/anaconda3

Finally, you can remove the PATH line from your .bashrc file that Anaconda added. To do so, first open a text editor such as nano:

nano ~/.bashrc

Then scroll down to the end of the file (if this is a recent install) or type CTRL + W to search for Anaconda. Delete or comment out this Anaconda block:

/home/sammy/.bashrc
...
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/sammy/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/sammy/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/sammy/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/sammy/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

While you’re executed enhancing the file, sort CTRL + X to exit and y to save lots of modifications.

Anaconda is now eliminated out of your server. In the event you didn’t deactivate the base programming setting, you’ll be able to exit and re-enter the server to take away it.

Conclusion

This tutorial walked you thru the set up of Anaconda, working with the conda command-line utility, establishing environments, updating Anaconda, and deleting Anaconda in the event you not want it.

You should utilize Anaconda that will help you handle workloads for information science, scientific computing, analytics, and large-scale information processing. From right here, you’ll be able to take a look at our tutorials on information evaluation and machine studying to study extra about varied instruments out there to make use of and tasks that you are able to do.

We even have a free machine studying e-book out there for obtain, Python Machine Studying Tasks.

We hope the How To Install the Anaconda Python Distribution on Ubuntu 20.04 help you. If you have any query regarding How To Install the Anaconda Python Distribution on Ubuntu 20.04 drop a comment below and we will get back to you at the earliest.

We hope this post helped you to find out  How To Install the Anaconda Python Distribution on Ubuntu 20.04  . You may also want to see – How to Install Apache on Ubuntu 20.04

Copy link
Powered by Social Snap