How To Install Anaconda on AlmaLinux 9 | Easy and Full Steps
In this guide from Orcacore, you will learn How To Install Anaconda on AlmaLinux 9. Anaconda is a popular distribution of Python and R, formerly known as Continuum Analytics. It’s designed for scientific computing, data science, machine learning, and statistical analysis. Anaconda comes pre-packaged with over 250 data science packages and provides access to over 7,500 additional open-source packages compatible with Windows, macOS, and Linux.
It also includes a GUI called the “Anaconda Navigator,” which offers a graphical alternative to the command-line interface (CLI).
To follow this guide, you’ll need to log in to your AlmaLinux 9 server as a non-root user with sudo privileges. You can set this up by referring to our guide on Initial Server Setup with AlmaLinux 9.
1. Installing Python 3 For Anaconda Setup
Since Anaconda is based on Python, you need Python installed on your server. AlmaLinux 9 typically has Python 3 installed by default.
First, update your local package index:
sudo dnf update -y
Then, verify Python 3 is installed:
python3 --version
**Output**
Python 3.9.10
If Python 3 isn’t present, install it using:
sudo dnf install python3 -y
2. Download and Install Anaconda Programming Language
Next, visit the Anaconda Downloads Page. In the Linux section, copy the link address for the Anaconda installer.
[Image of Anaconda installer for Linux]
Use the wget
command to download the Anaconda installer to your AlmaLinux 9 server. We will download it to the Downloads
directory.
sudo wget -P ~/Downloads https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
Now, navigate to your Downloads directory:
cd ~/Downloads
Verify the integrity of the downloaded Anaconda installer:
sha256sum Anaconda3-2022.05-Linux-x86_64.sh
The output will resemble:
**Output**
a7c0afe862f6ea19a596801fc138bde0463abcbce1b753e8d5c474b506a2db2d Anaconda3-2022.05-Linux-x86_64.sh
Compare this hash with the one on the Anaconda hashes web page. If they match, the software is authentic.
Install Anaconda on AlmaLinux 9 by running:
bash Anaconda3-2022.05-Linux-x86_64.sh
You’ll be prompted to review the license agreement. Press Enter, then use Enter or the Spacebar to scroll. Type yes to agree.
Confirm Anaconda’s installation directory by pressing Enter to accept the default.
You will then be asked to initialize Anaconda with conda init
. Press yes and Enter.
Upon completion, you will see output similar to this:
[Image of Anaconda installation output]
- Note: Avoid installing in the
/usr
directory. If you are not prompted to initialize Anaconda, enter the following commands:
source <anaconda_installation_location>/bin/activate
conda init
Reboot your server:
reboot
After rebooting, verify the installation with:
conda info
[Image of conda info output]
Load Python programming shell
Load the Python programming shell using:
python
The command prompt will change to:
Python 3.9.12 (main, Apr 5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Exit the Python shell with:
quit()
3. Update Anaconda on AlmaLinux 9
Update conda first:
conda update conda
Then, update Anaconda itself:
conda update anaconda
4. Remove Anaconda Programming Language
To remove Anaconda, install the removal software:
conda install anaconda-clean
Then, uninstall Anaconda:
anaconda-clean --yes
Conclusion
You have now successfully learned How To Install Anaconda on AlmaLinux 9. You also know how to update and remove it.
Hope you enjoy it.
How To Install PHP 8.1 on AlmaLinux 9
Install and Configure CSF Firewall on AlmaLinux 9
Alternative Solutions for Installing Anaconda on AlmaLinux 9
While the steps outlined above provide a straightforward method for installing Anaconda, alternative approaches exist that may be more suitable for specific use cases. Here are two different ways you can achieve the same goal.
1. Using Miniconda
Miniconda is a minimal installer for conda. It contains only conda, Python, the packages they depend on, and a few other useful packages, including pip, zlib and a few others. Use the conda command to install 7,200+ additional conda packages from Anaconda repositories.
Explanation:
Miniconda is a lighter alternative to Anaconda. Instead of installing a large suite of packages upfront, Miniconda provides a base installation with only the essential components. This approach is beneficial when you want more control over the packages installed in your environment or when disk space is a concern. You only install what you need, when you need it. This approach allows for a cleaner, more tailored environment.
Steps:
-
Download Miniconda: Visit the Miniconda website and copy the link for the Linux installer. Alternatively, you can use
wget
directly from the command line.wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
-
Install Miniconda: Run the downloaded script.
bash Miniconda3-latest-Linux-x86_64.sh
Follow the prompts in the installer, accepting the license agreement and choosing an installation location. Similar to the Anaconda installation, it’s recommended to avoid installing in the
/usr
directory. -
Initialize Miniconda: After installation, initialize conda by running:
source <miniconda_installation_location>/bin/activate conda init
Reboot your server.
reboot
-
Create and Manage Environments: With Miniconda installed, you can create and manage your Python environments using conda commands.
conda create --name myenv python=3.9 conda activate myenv
This will create a new environment named
myenv
with Python 3.9. You can then install the specific packages you need for your data science projects. For example, to install numpy and pandas, you can use:conda install numpy pandas
This approach gives you finer-grained control over your environment while still leveraging the power of the conda package manager. How To Install Anaconda on AlmaLinux 9 using Miniconda provides a great alternative.
2. Using Docker
Docker is a platform for developing, shipping, and running applications in containers. Containers are lightweight, portable, and self-sufficient environments that package everything an application needs to run, including code, runtime, system tools, libraries, and settings.
Explanation:
Using Docker to install Anaconda offers isolation and reproducibility. A Docker container encapsulates Anaconda and all its dependencies, ensuring a consistent environment regardless of the host system. This is particularly useful for collaboration, deploying applications, and avoiding dependency conflicts. It’s also beneficial if you want to try out Anaconda without making changes to your host system.
Steps:
-
Install Docker: If Docker is not already installed on your AlmaLinux 9 server, install it using the following commands:
sudo dnf install docker -y sudo systemctl start docker sudo systemctl enable docker
-
Pull the Anaconda Docker Image: Docker Hub provides pre-built Anaconda images. Pull the official Anaconda image using the
docker pull
command.docker pull continuumio/anaconda3
-
Run the Anaconda Docker Container: Create and run a container based on the pulled image.
docker run -it --name my_anaconda -p 8888:8888 continuumio/anaconda3 /bin/bash
-it
: Runs the container in interactive mode, allowing you to access the shell.--name my_anaconda
: Assigns a name to the container for easy management.-p 8888:8888
: Maps port 8888 on the host machine to port 8888 inside the container, allowing you to access Jupyter Notebook.continuumio/anaconda3
: Specifies the Docker image to use./bin/bash
: Executes the bash shell inside the container.
-
Access Anaconda within the Container: Once inside the container, you can use Anaconda as if it were installed directly on your system. You can start Jupyter Notebook, manage environments, and install packages using conda.
To start Jupyter Notebook:
jupyter notebook --ip 0.0.0.0 --port 8888 --allow-root
Then, open a web browser and navigate to
http://your_server_ip:8888
. The Jupyter Notebook interface will be accessible from your browser.
Example Dockerfile:
You can also create a Dockerfile to automate the Anaconda installation and configuration. Here’s a simple example:
FROM continuumio/anaconda3
# Set the working directory
WORKDIR /app
# Install any additional dependencies
RUN conda update -n base -c defaults conda
RUN conda install -c conda-forge pandas scikit-learn matplotlib
# Expose port 8888 for Jupyter Notebook
EXPOSE 8888
# Start Jupyter Notebook
CMD ["jupyter", "notebook", "--ip", "0.0.0.0", "--port", "8888", "--allow-root"]
To build and run this Dockerfile:
docker build -t my_anaconda .
docker run -it --name my_anaconda -p 8888:8888 my_anaconda
This How To Install Anaconda on AlmaLinux 9 method provides a consistent and isolated environment, making it easier to manage dependencies and deploy data science applications.
These two alternative methods, using Miniconda and Docker, offer flexibility and control over your Anaconda installation on AlmaLinux 9, catering to different needs and preferences. Both methods address the core problem of setting up a Python environment for data science but do so with different strengths and considerations.