Step-By-Step guide for Anaconda installation On Linux For Data Science

Step-By-Step guide for Anaconda installation On Linux For Data Science

Anaconda® is a powerful package manager, an environment manager, a Python/R data science distribution, and a collection of over 1,500+ open source packages. Anaconda is free and easy to install, and it offers free community support.

The Tutorial is divided into 4 parts:

  1. Installing Anaconda
  2. Testing Anaconda
  3. Setting Up virtual environment
  4. Installing packages

Part 1: Installing Anaconda on Linux

Official Anaconda Homepage
Official Anaconda Homepage
  • Click the download button on the top right corner.
Anaconda distribution download page
Anaconda distribution download page
  • Choose linux
Download anaconda
Download anaconda
  • Click on the download button for Python 3.7 version.
Download Anaconda python 3.7 for linux
Download Anaconda for linux
  • The Downloaded file will be saved in the default download folder of your web-browser
Downloading anaconda in default downloads folder
Downloading anaconda in default downloads folder
  • Open the linux termial by pressing Ctrl+Alt+T
Linux Terminal
Linux Terminal
  • In the terminal we have to run 3 commands to make your our linux version is updated with the latest and necessary packages.
    • sudo apt-get upgrade
    • sudo apt-get update
    • sudo apt-get dist-upgrade
Update and Upgrade linux
Update and Upgrade linux
  • Now we have to execute the file which we downloaded from the anaconda website.
    • Navigate to the folder in which the downloaded file is saved by using cd command. In my case the downloaded file is saved in /Downloads directory
    • Check if the file named ” Anaconda3-2019.03-Linux-x86_64.sh” is present by using ls command
  • To run the .sh file we use the bash command followed by the file name
    • bash Anaconda3-2019.03-Linux-x86_64.sh
Install Anaconda file in download folder using bash command
Install Anaconda file in download folder using bash command
  • Press Enter to continue the installation then type ‘yes‘.The installaton will start.
Insatalling anaconda
Insatalling anaconda
  • If the installation shows no error, Anaconda is installed
Anaconda Installed
Anaconda Installed

Part 2: Testing Anaconda

  • Type conda list in the terminal window. This will show all the python packages which are currently installed.
  • If terminal shows an error “conda command not found“.
    • nano /home/username/.bashrc
    • add the text “export PATH=~/anaconda3/bin:$path
    • save the file pressing Ctrl+X the Y and then Enter.
    • Type the command in terminal “ source /home/username/.bashrc
    • Close the terminal and run a new terminal.
Define conda in variable path linux .bashrc
Define conda in variable path linux .bashrc
  • To check the python version installed run commandpython3 --version
  • To check the conda version installed run the commandconda --version
  • Run the command “conda init” to initialize the conda package manager and its base environment.
initializing conda base environment (base)
initializing conda base environment (base)
  • You can observe (base) written before the prompt. This base is by default conda base environment. We can setup our own virtual environment too.
(base) before prompt indicating base environment
(base) before prompt indicating base environment

Part 3: Setting up our own Virtual Environment

  • To Setup our own virtual environment we have to write the command
    • conda create -n venv1 python=3.7 anaconda (where venv1 is name of virtual environment)
Creating own virtual environment "venv1"
Creating own virtual environment “venv1”
  • To deactivate a virtual environment write the command
    • conda deactivate
  • To activate a virtual environment write the command
    • conda activate venv1 (where venv1 is the virtual environment name
  • Now you can see (venv1) instead of (base) before prompt in the terminal window.
(venv1) before prompt indicating custom virtual environment "venv1"
(venv1) before prompt indicating custom virtual environment “venv1”

Part 4: Installing Packages in virtual environment

  • Activate the virtual environment in which you want to install the python package.
  • Type command conda search numpy to search the anaconda database for the python package.
  • Type Command conda install numpy to install the python numpy package.
  Installing numpy package in virtual environment
Installing numpy package in virtual environment
  • If a package is not available in the anaconda database you can use the command conda install -c conda-forge tweepy
  • Run command conda list to check if the python package is installed or not.
Installing packages using conda forge
Installing packages using conda forge

Finally Run Command anaconda-navigator to open the anaconda navigator and explore PYTHON “jupyter notebook”, “spyder3 IDE”, “VScode”, “RStudio”

Anaconda Navigtor
Anaconda Navigator

Thank you for reading, Happy Learning, drop your suggestion in the comments.

Feel free to follow us on Youtube, Linked In , Instagram

Loading comments...
Mastodon