Installing Anaconda on Linux

how to install anaconda on linux command line | 2019-10-09 18:36:53

Installing Anaconda on Linux

This section details the installation of the Anaconda distribution of Python on Linux, specifically Ubuntu 18.04, but the instructions should work for other Debian-based Linux distributions as well.

Ubuntu 18.04 comes pre-installed with Python (Version 3.6) and legacy Python (Version 2.7). You can confirm the legacy version of Python is installed by opening up a terminal.

In the terminal type:

$ python

You will most likely see Python Version 2.7 is installed. If you enter:

$ python3

You will most likely see Python Version 3.6 is also installed. You can use the 3.6 Version of Python, but each time a new package needs to be downloaded, the $ pip3 install command must be used.

Install the Anaconda distribution of Python to follow the examples in the book without the need to install additional third-party packages.

Steps:

  1. Visit Anaconda.com/downloads

  2. Select Linux

  3. Copy the bash (.sh file) installer link

  4. Use wget to download the bash installer

  5. Run the bash script to install Anaconda3

  6. source the .bash-rc file to add Anaconda to your PATH

  7. Start the Python REPL

1. Visit the Anaconda downloads page

Go to the following link: Anaconda.com/downloads

2. Select Linux

On the downloads page, select the Linux operating system

3. Copy the bash (.sh file) installer link

In the Python 3.6 Version* box, right-click on the [64-Bit(x86) Installer] link. Select [copy link address].

4. Use wget to download the bash installer

Now that the bash installer (.sh file) link is stored on the clipboard, use wget to download the installer script. In a terminal, cd into the home directory and make a new directory called tmp. cd into tmp and use wget to download the installer. Although the installer is a bash script, it is still quite large and the download will not be immediate (Note the link below includes <release>. the specific release depends on when you download the installer).

$ cd ~
$ mkdir tmp
$ cd tmp
$ https://repo.continuum.io/archive/Anaconda3<release>.sh

5. Run the bash script to install Anaconda3

With the bash installer script downloaded, run the .sh script to install Anaconda3. Ensure you are in the directory where the installer script downloaded:

$ ls
Anaconda3-5.2.0-Linux-x86_64.sh

Run the installer script with bash.

$ bash Anaconda3-5.2.0-Linux-x86_64.sh

Accept the Licence Agreement and allow Anaconda to be added to your PATH. By adding Anaconda to your PATH, the Anaconda distribution of Python will be called when you type $ python in a terminal.

6. source the .bash-rc file to add Anaconda to your PATH

Now that Anaconda3 is installed and Anaconda3 is added to our PATH, source the .bashrc file to load the new PATH environment variable into the current terminal session. Note the .bashrc file is in the home directory. You can see it with $ ls -a.

$ cd ~
$ source .bashrc

7. Start the Python REPL

To verify the installation is complete, open Python from the command line:

$ python

Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 18:21:58)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

If you see Python 3.6 from Anaconda listed, your installation is complete. To exit the Python REPL, type:

>>> exit()

Installing on Linux — Anaconda 2.0 documentation

Debianapt-getinstalllibgl1-mesa-glxlibegl1-mesalibxrandr2libxrandr2libxss1libxcursor1libxcomposite1libasound2libxi6libxtst6
RedHatyuminstalllibXcompositelibXcursorlibXilibXtstlibXrandralsa-libmesa-libEGLlibXdamagemesa-libGLlibXScrnSaver
ArchLinuxpacman-Sylibxaulibxilibxsslibxtstlibxcursorlibxcompositelibxdamagelibxfixeslibxrandrlibxrendermesa-libglalsa-liblibglvnd
OpenSuse/SLESzypperinstalllibXcomposite1libXi6libXext6libXau6libX11-6libXrandr2libXrender1libXss1libXtst6libXdamage1libXcursor1libxcb1libasound2libX11-xcb1Mesa-libGL1Mesa-libEGL1
Gentooemergex11-libs/libXaux11-libs/libxcbx11-libs/libX11x11-libs/libXextx11-libs/libXfixesx11-libs/libXrenderx11-libs/libXix11-libs/libXcompositex11-libs/libXrandrx11-libs/libXcursorx11-libs/libXdamagex11-libs/libXScrnSaverx11-libs/libXtstmedia-libs/alsa-libmedia-libs/mesa

Installation For x86 systems. In your browser, download the Anaconda installer for Linux Optional: Verify data integrity with MD5 or SHA-256 . (For more information on hashes, see cryptographic hash validation Open a terminal and run the following: filename sha256sum filename Replace /path/filename with the actual path and filename of the file you downloaded. Optional: Verify results against the proper hash page to make sure the hashes match. Enter the following to install Anaconda for Python 3.7: Downloads Anaconda3 2019.07 OR Enter the following to install Anaconda for Python 2.7: Downloads Anaconda2 2019.07 Include the command regardless of whether or not you are using Bash shell. If you did not download to your Downloads directory, replace ~/Downloads/ with the path to the file you downloaded. The installer prompts “In order to continue the installation process, please review the license agreement.” Click Enter to view license terms. Scroll to the bottom of the license terms and enter “Yes” to agree. The installer prompts you to click Enter to accept the default install location, CTRL-C to cancel the installation, or specify an alternate installation directory. If you accept the default install location, the installer displays “PREFIX=/home//anaconda<2 or 3>” and continues the installation. It may take a few minutes to complete. We recommend you accept the default install location. Do not choose the path as /usr for the Anaconda/Miniconda installation. The installer prompts “Do you wish the installer to initialize Anaconda3 by running conda init?” We recommend “yes”. If you enter “no”, then conda will not modify your shell scripts at all. In order to initialize after the installation process is done, first run conda>/bin/activate and then run The installer finishes and displays “Thank you for installing Anaconda<2 or 3>!” The installer provides a link to install PyCharm for Anaconda at https://www.anaconda.com/pycharm Close and open your terminal window for the installation to take effect, or you can enter the command ~/.bashrc To control whether or not each shell session has the base environment activated or not, run auto_activate_base . To run conda from anywhere without having the base environment activated by default, use auto_activate_base . This only works if you have run is available in conda versions 4.6.12 and later. After your install is complete, verify it by opening Anaconda Navigator, a program that is included with Anaconda: Open a terminal window and type anaconda-navigator . If Navigator opens, you have successfully installed Anaconda. If not, check that you completed each step above, then see our Help page For more information about Anaconda Navigator, see Navigator After your install completes, start using Anaconda with the instructions in Getting started with Anaconda If you install multiple versions of Anaconda, the system defaults to the most current version as long as you haven’t altered the default install path.

How To Install Anaconda on Ubuntu 18.04 [Quickstart]

Introduction

Designed for data science and machine learning workflows, 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 Anaconda on an Ubuntu 18.04 server. For a more detailed version of this tutorial, with better explanations of each step, please refer to How To Install the Anaconda Python Distribution on Ubuntu 18.04.

Step 1 — Retrieve the Latest Version of Anaconda

From a web browser, go to the Anaconda Distribution page, available via the following link:

https://www.anaconda.com/distribution/

Find the latest Linux version and copy the installer bash script.

Step 2 — Download the Anaconda Bash Script

Logged into your Ubuntu 18.04 server as a sudo non-root user, move into the /tmp directory and use curl to download the link you copied from the Anaconda website:

Step 3 — Verify the Data Integrity of the Installer

Ensure the integrity of the installer with cryptographic hash verification through SHA-256 checksum:

Output
45c851b7497cc14d5ca060064394569f724b67d9b5f98a926ed49b834a6bb73a Anaconda3-2019.03-Linux-x86_64.sh

Step 4 — Run the Anaconda Script

You’ll receive the following output to review the license agreement by pressing ENTER until you reach the end.

Output
Welcome to Anaconda3 2019.03 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue >>> ... Do you approve the license terms? [yes|no]

When you get to the end of the license, type yes as long as you agree to the license to complete installation.

Step 5 — Complete Installation Process

Once you agree to the license, you will be prompted to choose the location of the installation. You can press ENTER to accept the default location, or specify a different location.

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

At this point, the installation will proceed. Note that the installation process takes some time.

Step 6 — Select Options

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

Output
... installation finished. Do you wish the installer to prepend the Anaconda3 install location to PATH in your /home/sammy/.bashrc ? [yes|no] [no] >>>

It is recommended that you type yes to use the conda command.

Step 7 — Activate Installation

You can now activate the installation with the following command:

Step 8 — Test Installation

Use the conda command to test the installation and activation:

You’ll receive output of all the packages you have available through the Anaconda installation.

Step 9 — Set Up Anaconda Environments

You can create Anaconda environments with the conda create command. For example, a Python 3 environment named my_env can be created with the following command:

Activate the new environment like so:

Your command prompt prefix will change to reflect that you are in an active Anaconda environment, and you are now ready to begin work on a project.

Related Tutorials

Here are links to more detailed tutorials that are related to this guide:

Installing on Linux — conda 4.7.11.post28+0fbd418f documentation

Download the installer: Miniconda installer for Linux Anaconda installer for Linux

In your terminal window, run: Miniconda: Miniconda3 Anaconda: Anaconda

Follow the prompts on the installer screens. If you are unsure about any setting, accept the defaults. You can change them later.

To make the changes take effect, close and then re-open your terminal window.

Test your installation

Open a terminal window.

Open a terminal window.

Remove the entire miniconda install directory with: miniconda

OPTIONAL: Edit ~/.bash_profile to remove the Miniconda directory from your PATH environment variable.

OPTIONAL: Remove the following hidden file and folders that may have been created in the home directory: .condarc directory .continuum directory By running: condarc continuum

How to Install Anaconda on Ubuntu 18.04

Anaconda is the most popular python data science and machine learning platform, used for large-scale data processing, predictive analytics, and scientific computing. Anaconda distribution ships with more than 1,000 data packages, the conda command-line tool and with a desktop graphical user interface called Anaconda Navigator.

This tutorial will guide you through the steps of downloading and installing Anaconda Python Distribution on Ubuntu 18.04.

Installing Anaconda

At the time of writing this article, the latest stable version of Anaconda is version 5.2. Before downloading the Anaconda installer script visit the Anaconda Downloads page and check if there is a new version of Anaconda for Python 3 available for download.

Follow the steps below to install Anaconda on Ubuntu 18.04:

  1. Download the Anaconda Installation Script.

    Change to the tmp directory and download the Anaconda installation script with wget or curl:

    cd /tmp
    curl -O https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh

    The download may take some time depending on your connection speed.

  2. Verify the Data Integrity of the Script.

    Use the sha256sum command to verify the script checksum:

    sha256sum Anaconda3-5.2.0-Linux-x86_64.sh

    You should see an output like the following:

    09f53738b0cd3bb96f5b1bac488e5528df9906be2480fe61df40e0e0d19e3d48  Anaconda3-5.2.0-Linux-x86_64.sh

    Make sure the hash printed from the command above matches the one available at the Anaconda with Python 3 on 64-bit Linux page for your appropriate Anaconda version.

    https://docs.anaconda.com/anaconda/install/hashes/Anaconda3-5.2.0-Linux-x86_64.sh-hash.html
  3. Run the Anaconda Installation Script

    To start the Anaconda installation process run the installation script:

    bash Anaconda3-5.2.0-Linux-x86_64.sh

    You should see an output like the following:

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

    Press ENTER to continue and then press ENTER to scroll through the license. Once you’re done reviewing the license, you’ll be asked to approve the license terms:

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

    Type yes to accept the license and you’ll be prompted to choose the installation location.

    Anaconda3 will now be installed into this location:
    /home/linuxize/anaconda3
    
        - Press ENTER to confirm the location
        - Press CTRL-C to abort the installation
        - Or specify a different location below

    The default location is fine for most users, press ENTER to confirm the location and installation process will continue.

    The installation may take some time and once it is completed, the following output will be displayed:

    Installation finished.
    Do you wish the installer to prepend the Anaconda3 install location
    to PATH in your /home/linuxize/.bashrc ? [yes|no]

    If you want to use the conda command type yes press ENTER and you’ll be presented the following output:

    Appending source /home/linuxize/anaconda3/bin/activate to /home/linuxize/.bashrc
    A backup will be made to: /home/linuxize/.bashrc-anaconda3.bak
    
    For this change to become active, you have to open a new terminal.
    
    Thank you for installing Anaconda3!

    The installer will also ask you whether you would like to download and install Visual Studio Code.

    Anaconda is partnered with Microsoft! Microsoft VSCode is a streamlined
    code editor with support for development operations like debugging, task
    running and version control.
    
    To install Visual Studio Code, you will need:
        - Administrator Privileges
        - Internet connectivity
    
    Visual Studio Code License: https://code.visualstudio.com/license
    
    Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]

    You can find more information about Visual Studio on the editor website. If you want to install Visual Studio Code type yes otherwise type no.

    To activate the Anaconda installation load the new PATH environment variable which was added by the Anaconda installer into the current shell session with the following command:

    source ~/.bashrc
  4. Verify the Installation

    You can verify your Anaconda installation using the conda command. For example to display information about current conda install type:

    conda info
    activeenvironment:Noneuserconfigfile:/home/linuxize/.condarcpopulatedconfigfiles:condaversion:4.5.4conda-buildversion:3.10.5pythonversion:3.6.5.final.0baseenvironment:/home/linuxize/anaconda3(writable)channelURLs:https://repo.anaconda.com/pkgs/main/linux-64
    https://repo.anaconda.com/pkgs/main/noarch
    https://repo.anaconda.com/pkgs/free/linux-64
    https://repo.anaconda.com/pkgs/free/noarch
    https://repo.anaconda.com/pkgs/r/linux-64
    https://repo.anaconda.com/pkgs/r/noarch
    https://repo.anaconda.com/pkgs/pro/linux-64
    https://repo.anaconda.com/pkgs/pro/noarch
    packagecache:/home/linuxize/anaconda3/pkgs/home/linuxize/.conda/pkgsenvsdirectories:/home/linuxize/anaconda3/envs/home/linuxize/.conda/envsplatform:linux-64user-agent:conda/4.5.4requests/2.18.4CPython/3.6.5Linux/4.15.0-22-genericubuntu/18.04glibc/2.27UID:GID:1000:1000netrcfile:Noneofflinemode:False

Updating Anaconda

Updating the Anaconda is a pretty straight forward process, first update the conda tool with:

conda update conda

When prompted to confirm the update, type y to proceed.

Once conda is updated, proceed with the Anaconda update:

conda update anaconda

Same as with the previous command, when prompted, type y to proceed.

You should regularly update your Anaconda installation.

Uninstalling Anaconda

If you want to uninstall Anaconda from your Ubuntu system, follow the steps below:

  1. Remove the Anaconda install directory.

    To remove the entire Anaconda installation directory type:

    rm -rf ~/anaconda3
  2. Edit the PATH environment variable.

    Edit the ~/.bashrc file and remove the Anaconda directory from the PATH environment variable:

    ~/.bashrc
    # added by Anaconda3 installerexportPATH="/home/linuxize/anaconda3/bin:$PATH"
  3. Remove the hidden files.

    The following rm command will remove the hidden files and folders that have been created in your user home directory:

    rm -rf ~/.condarc ~/.conda ~/.continuum

Conclusion

Now that you have downloaded and installed Anaconda your Ubuntu system, you can check the official Getting started with conda guide.

If you hit a problem or have feedback, leave a comment below.

ubuntuanaconda