Best Steps To Set up Anaconda on Rocky Linux 8 – OrcaCore

Posted on

Best Steps To Set up Anaconda on Rocky Linux 8 - OrcaCore

Best Steps To Set up Anaconda on Rocky Linux 8 – OrcaCore

Anaconda is a powerful, open-source distribution of Python and R, specifically designed for data science, machine learning, and scientific computing. Its core strength lies in simplifying package management and deployment, thanks to the conda package manager. conda intelligently analyzes your environment before installing new packages, ensuring compatibility and preventing conflicts with existing frameworks.

This tutorial, brought to you by OrcaCore, guides you through the process of setting up Anaconda on Rocky Linux 8. We’ll cover everything from initial Python installation to verifying your Anaconda setup and even uninstalling it if needed.

Before we begin, ensure you’re logged into your Rocky Linux 8 server as a non-root user with sudo privileges. If you haven’t already, refer to our guide on Initial Server Setup with Rocky Linux 8 for instructions.

1. Install Python 3 on Rocky Linux 8

While Anaconda comes with its own Python distribution, it’s good practice to have Python 3 installed system-wide.

First, update your local package index:

sudo dnf update -y

Next, install Python 3:

sudo dnf install python3 -y

Verify the installation:

python3 --version
**<mark>Output</mark>**
Python 3.6.8

Note: The version number may vary depending on your Rocky Linux 8 installation.

2. Install Anaconda on Rocky Linux 8

Download Anaconda Installer

Visit the Anaconda Downloads Page. In the Linux section, copy the link address for the Anaconda installer.

Anaconda installer

Now, use the wget command to download the installer to your Downloads directory (or any location you prefer):

sudo wget -P ~/Downloads https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh

Navigate to the Downloads directory:

cd ~/Downloads

Verify the integrity of the downloaded file using sha256sum:

sha256sum Anaconda3-2022.10-Linux-x86_64.sh

You should see an output similar to:

Download Anaconda Installer

Compare this hash with the one provided on the Anaconda hashes web page. If they match, the file is authentic.

Install Anaconda

Execute the installer:

sudo bash Anaconda3-2022.10-Linux-x86_64.sh

You’ll be prompted to review the license agreement. Press Enter to begin scrolling and use Enter or the Spacebar to navigate. Type yes to accept the license.

Next, confirm the installation directory by pressing Enter to accept the default.

When asked to initialize Anaconda with conda init, type yes and press Enter.

Upon completion, you’ll see output similar to this:

Run Anaconda Installer

Important Note: Avoid installing Anaconda in the /usr directory. If you weren’t prompted to initialize Anaconda during the installation, run the following commands:

source <anaconda_installation_location>/bin/activate
conda init

Replace <anaconda_installation_location> with the actual path where you installed Anaconda.

Reboot your server:

sudo reboot

After rebooting, verify the installation:

conda info

Anaconda installation on Rocky Linux 8

Load Anaconda Python Shell

You can load the Anaconda Python shell with:

python

Your prompt will change to something like:

Python 3.9.13 (main, Aug 25 2022, 23:26:10)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Exit the Python shell using:

quit()

3. Update Anaconda on Rocky Linux 8

Keep your Anaconda distribution up-to-date. First, update conda:

conda update conda

Then, update Anaconda itself:

conda update anaconda

4. Uninstall Anaconda

If you need to remove Anaconda, first install the anaconda-clean package:

conda install anaconda-clean

Then, uninstall Anaconda:

anaconda-clean --yes

Conclusion

This tutorial provided a comprehensive guide on how to Set up Anaconda on Rocky Linux 8. By following these steps, you’ll have a fully functional Anaconda environment ready for your data science and machine learning projects. Ensuring Python is installed and verifying the integrity of the installer are key to a successful installation. The OrcaCore team hopes you found this guide helpful.

You might also be interested in:

Alternative Solutions for Installing Anaconda on Rocky Linux 8

While the method described above is the standard and recommended way to install Anaconda, here are two alternative approaches you can consider:

1. Using Miniconda:

Miniconda is a minimal installer for conda. It only includes conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. If you prefer a leaner installation and want to manage packages more explicitly, Miniconda is an excellent choice.

Explanation:

Anaconda comes with a large number of pre-installed packages, many of which you might not need for your specific projects. Miniconda allows you to start with a bare-bones environment and install only the packages you require, leading to a smaller footprint and potentially fewer dependency conflicts. This approach is particularly useful for developers who prefer fine-grained control over their environment.

Steps:

  1. Download the Miniconda Installer: Visit the Miniconda website and download the appropriate installer for Linux (x86_64). Use wget to download to your server, similar to the Anaconda instructions.

    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
  2. Install Miniconda: Run the installer script:

    bash Miniconda3-latest-Linux-x86_64.sh

    Follow the on-screen prompts. Accept the license, choose the installation location, and initialize Miniconda.

  3. Activate the Base Environment: After installation, activate the base environment:

    conda activate
  4. Create and Manage Environments: Create environments as needed and install the specific packages you require using conda install.

    conda create -n myenv python=3.9
    conda activate myenv
    conda install numpy pandas scikit-learn

2. Using Docker Container:

Docker provides a way to containerize applications and their dependencies, ensuring consistency across different environments. You can use a pre-built Anaconda Docker image or create your own.

Explanation:

Docker offers a completely isolated environment for your Anaconda installation. This eliminates dependency conflicts and ensures that your data science projects run consistently, regardless of the underlying operating system or other software installed on the host machine. This approach is beneficial for reproducibility, collaboration, and deploying applications to different environments.

Steps:

  1. Install Docker: If you don’t have Docker installed, follow the instructions on the Docker website for Rocky Linux 8.

  2. Pull an Anaconda Docker Image: Use the docker pull command to download a pre-built Anaconda image from Docker Hub.

    docker pull continuumio/anaconda3
  3. Run a Docker Container: Create and run a container from the image:

    docker run -it --name my_anaconda_container continuumio/anaconda3 /bin/bash

    This command creates a container named my_anaconda_container, starts it in interactive mode (-it), and opens a bash shell inside the container.

  4. Use Anaconda within the Container: You can now use Anaconda and its tools within the container as if it were installed directly on your system.

    conda info
    python
  5. Optional: Mount a Volume for Persistent Storage: To persist your data and projects between container sessions, mount a volume:

    docker run -it -v /path/to/your/data:/home/anaconda/data --name my_anaconda_container continuumio/anaconda3 /bin/bash

    Replace /path/to/your/data with the actual path on your host machine where you want to store your data. This will create a shared directory between your host and the container.

These alternative solutions provide flexibility and cater to different needs and preferences. Miniconda offers a lightweight approach with greater control over package selection, while Docker provides a completely isolated and reproducible environment for your Anaconda installation. Remember to choose the method that best suits your workflow and project requirements for setting up Anaconda on Rocky Linux 8.

Leave a Reply

Your email address will not be published. Required fields are marked *