- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Install Anaconda on CentOS 7?
Anaconda is a free and open-source distribution of Python programming language. It is widely used in data science, machine learning, and artificial intelligence. Anaconda comes with a package manager and a set of pre-installed libraries that make it easy for developers to start working on data science projects without worrying about installing dependencies. In this article, we will discuss how to install Anaconda on CentOS 7.
Prerequisites
Before we start installing Anaconda, make sure you have following prerequisites −
A CentOS 7 server with root access.
A stable internet connection.
At least 4 GB of RAM.
At least 10 GB of free disk space.
Step 1: Update System
Firstly, you need to update your CentOS 7 system to ensure that all packages are up-to-date. To do this, run following commands in your terminal −
sudo yum update -y sudo yum upgrade -y
Step 2: Download Anaconda
Next, you need to download Anaconda installation script. You can download script using following command −
wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
Note − You can check for latest version of Anaconda by visiting official website.
Step 3: Verify Data Integrity
After downloading installation script, you need to verify its data integrity by comparing its SHA-256 checksum with one provided on Anaconda website. To do this, run following command −
sha256sum Anaconda3-2021.05-Linux-x86_64.sh
You should see an output similar to following −
45c851b7497cc14d5ca060064394569f724b67d9b5f98a926ed49b834a6bb73a Anaconda3-2021.05-Linux-x86_64.sh
Compare first 8 characters of output with SHA-256 checksum provided on Anaconda website. If they match, installation script is valid and you can proceed to next step.
Step 4: Run Anaconda Installation Script
Once you have verified data integrity of Anaconda installation script, you can run it using following command −
bash Anaconda3-2021.05-Linux-x86_64.sh
You will see a prompt asking you to review license agreement. Scroll down to end of agreement and type 'yes' to accept terms and conditions. Then, follow on-screen prompts to complete installation. You can choose default installation location or specify a custom location. It is recommended to use default location.
Note − During installation process, Anaconda will ask you whether you want to add Anaconda to your PATH environment variable. Type 'yes' to add it automatically.
Step 5: Verify Installation
Once installation is complete, you need to verify it by running following command −
conda --version
If installation was successful, you should see version number of Anaconda that you have installed.
Step 6: Create a New Environment
You can create a new environment using following command −
conda create --name myenv python=3.8
This command creates a new environment called 'myenv' with Python version 3.8. You can replace 'myenv' with any name you want.
Step 7: Activate Environment
To activate new environment, run following command −
conda activate myenv
This command activates 'myenv' environment. You should see the name of environment in your terminal prompt.
Step 8: Install Packages
Once you have activated new environment, you can install packages using following command −
conda install package_name
This command installs specified package in 'myenv' environment. You can replace 'package_name' with name of package you want to install.
Step 9: Deactivate Environment
When you are done working in 'myenv' environment, you can deactivate it using following command −
conda deactivate
This command deactivates current environment and returns you to base environment.
In addition to steps outlined above, there are some additional tips that can help you get most out of Anaconda on CentOS 7 −
Updating Anaconda − After you have installed Anaconda, it is important to keep it up-to-date. You can update Anaconda using following command −
conda update anaconda
This command updates all packages that come with Anaconda to their latest versions.
Creating a virtual environment − Anaconda allows you to create virtual environments that are isolated from base environment. This makes it easier to manage dependencies and avoid conflicts between different packages. You can create a virtual environment using following command −
conda create --name myenv
Replace 'myenv' with name of your environment. You can then activate environment using 'conda activate' command.
Installing packages from other channels − Anaconda comes with a default channel that contains many popular packages. However, there may be times when you need to install a package that is not available on default channel. In this case, you can add a new channel using following command −
conda config --add channels channel_name
Replace 'channel_name' with name of channel you want to add. You can then install packages from new channel using 'conda install' command.
Creating a requirements file − If you are working on a project that requires specific packages, you can create a requirements file that lists all required packages. This makes it easier to reproduce project on another machine or share it with other developers. You can create a requirements file using following command −
conda list --explicit > requirements.txt
This command creates a file called 'requirements.txt' that lists all packages installed in current environment.
Managing packages with conda − Conda is a powerful package manager that comes with Anaconda. You can use conda to install, update, and remove packages, as well as create and manage virtual environments. For example, you can update all packages in your environment using following command −
conda update --all
You can also remove a package using following command −
conda remove package_name
Replace 'package_name' with name of package you want to remove.
Using Jupyter Notebook − Jupyter Notebook is an interactive web-based environment for data science and machine learning. It allows you to write and execute code, visualize data, and share your work with others. Anaconda comes with Jupyter Notebook pre-installed, so you can start using it right away. To start Jupyter Notebook, run following command −
jupyter notebook
This command opens Jupyter Notebook in your default web browser. You can then create a new notebook and start writing code.
Using Anaconda Navigator − Anaconda Navigator is a graphical user interface that allows you to manage packages and environments, launch Jupyter Notebook, and access other tools and services. You can start Anaconda Navigator using following command −
anaconda-navigator
This command opens Anaconda Navigator in your default web browser. You can then use interface to manage your packages and environments, launch Jupyter Notebook, and more.
Configuring Anaconda − Anaconda comes with a number of configuration options that allow you to customize its behavior. For example, you can set default Python version, specify a different installation directory, or configure proxy settings. You can view current configuration using following command −
conda config --show
This command displays current configuration options. You can then modify configuration using 'conda config' command.
Installing packages from PyPI − In addition to default channel, Anaconda allows you to install packages from Python Package Index (PyPI). You can install a package from PyPI using following command −
conda install -c conda-forge package_name
Replace 'package_name' with name of package you want to install. '-c conda-forge' option specifies channel from which to install package.
Managing environments with YAML files − You can manage your Anaconda environments using YAML files. A YAML file is a text file that contains a list of packages and their versions. You can create a YAML file using following command −
conda env export > environment.yaml
This command creates a YAML file called 'environment.yaml' that contains a list of all packages in current environment. You can then use YAML file to recreate environment on another machine using following command −
conda env create -f environment.yaml
This command creates a new environment based on packages listed in YAML file.
Using conda-forge − conda-forge is a community-led collection of recipes, build infrastructure, and distributions of conda packages. It provides a large number of packages that are not available on default channel. To use conda-forge, you can add it as a new channel using following command −
conda config --add channels conda-forge
After adding conda-forge channel, you can install packages from it using 'conda install' command.
Conclusion
In this article, we have discussed how to install Anaconda on CentOS 7. We have also discussed how to create a new environment, activate it, install packages, and deactivate it. Anaconda is a powerful tool for data science and machine learning, and it is essential for developers to know how to install and use it. By following steps outlined in this article, you can easily install Anaconda and start working on your data science projects.