When it comes to data science, machine learning, or managing AI projects, having the right tools can make all the difference. Anaconda is a powerful library that simplifies managing packages, dependencies, and environments for Python-based projects. If you’re working actively with the development of AI models or a beginner looking forward to entering the data science industry, installing Anaconda sets you up with everything you need to hit the ground running.
This guide will show you the step-by-step process for installing Anaconda on Ubuntu using the installer script and initializing the “conda
” environment to start building with it.
Prerequisites
- A Virtual Machine (such as the ones provided by NodeShift) with at least:
- 2 vCPUs
- 4 GB RAM
- 20 GB SSD
- Ubuntu 22.04 VM
Note: The prerequisites for this are highly variable across use cases. For a large-scale deployment, one could use a high-end configuration.
Step-by-step process to install Anaconda on Ubuntu 22.04
For this tutorial, we’ll use a CPU-powered Virtual Machine by NodeShift, which provides high-compute Virtual Machines at a very affordable cost on a scale that meets GDPR, SOC2, and ISO27001 requirements. It also offers an intuitive and user-friendly interface, making it easier for beginners to get started with Cloud deployments. However, feel free to use any cloud provider you choose and follow the same steps for the rest of the tutorial.
Step 1: Setting up a NodeShift Account
Visit app.nodeshift.com and create an account by filling in basic details, or continue signing up with your Google/GitHub account.
If you already have an account, login straight to your dashboard.
Step 2: Create a Compute Node (CPU Virtual Machine)
After accessing your account, you should see a dashboard (see image), now:
- Navigate to the menu on the left side.
- Click on the Compute Nodes option.
- Click on Start to start creating your very first compute node.
These Compute nodes are CPU-powered virtual machines by NodeShift. These nodes are highly customizable and let you control different environmental configurations, such as vCPUs, RAM, and storage, according to your needs.
Step 3: Select configuration for VM
- The first option you see is the Reliability dropdown. This option lets you choose the uptime guarantee level you seek for your VM (e.g., 99.9%).
- Next, select a geographical region from the Region dropdown where you want to launch your VM (e.g., United States).
- Most importantly, select the correct specifications for your VM according to your workload requirements by sliding the bars for each option.
Step 4: Choose VM Configuration and Image
- After selecting your required configuration options, you’ll see the available VMs in your region and as per (or very close to) your configuration. In our case, we’ll choose a ‘2vCPUs/4GB/80GB SSD’ as the closest match to the “Prerequisites”.
- Next, you’ll need to choose an image for your Virtual Machine. For the scope of this tutorial, we’ll select Ubuntu, as we will install Anaconda on Ubuntu.
Step 5: Choose the Billing cycle and Authentication Method
- Two billing cycle options are available: Hourly, ideal for short-term usage, offering pay-as-you-go flexibility, and Monthly for long-term projects with a consistent usage rate and potentially lower cost.
- Next, you’ll need to select an authentication method. Two methods are available: Password and SSH Key. We recommend using SSH keys, as they are a more secure option. To create one, head over to our official documentation.
Step 6: Finalize Details and Create Deployment
Finally, you can also add a VPC (Virtual Private Cloud), which provides an isolated section to launch your cloud resources (Virtual machine, storage, etc.) in a secure, private environment. We’re keeping this option as the default for now, but feel free to create a VPC according to your needs.
Also, you can deploy multiple nodes at once using the Quantity option.
That’s it! You are now ready to deploy the node. Finalize the configuration summary; if it looks good, go ahead and click Create to deploy the node.
Step 7: Connect to active Compute Node using SSH
As soon as you create the node, it will be deployed in a few seconds or a minute. Once deployed, you will see a status Running in green, meaning that our Compute node is ready to use!
Once your node shows this status, follow the below steps to connect to the running VM via SSH:
- Open your terminal and run the below SSH command:
(replace root
with your username and paste the IP of your VM in place of ip
after copying it from the dashboard)
ssh root@ip
2. In some cases, your terminal may take your consent before connecting. Enter ‘yes’.
3. A prompt will request a password. Type the SSH password, and you should be connected.
Output:
Step 8: Download the Anaconda installer
First, we need to download the Anaconda installer that will further help us to install Anaconda in the system. Use the following command to download the installer:
- Update the system package source-list and upgrade the softwares.
apt update && apt upgrade -y
Output:
2. Add a non-administrative user
To avoid any accidental changes to the entire system, we’ll create a non-root or non-administrative user, and do all the installations with that user account.
For the demonstration purposes, we’ll create a user named “demo” and log in as the demo user:
(replace demo
with your preferred username)
adduser demo-user
usermod -aG sudo demo-user
su - demo-user
Output:
3. Navigate to tmp
directory
Next, move to the tmp
directory to isolate the installation from your working directory
cd /tmp
4. Download the installer
Use the below command to download the installation script that will be used to install Anaconda and rename it to anaconda.sh
wget -O anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh
Output:
Step 9: Verify the installer script
Next, use the below command to get the checksum of the downloaded script.
sha256sum anaconda.sh
Output:
To ensure that the downloaded script is not corrupted, match the checksum you got in the above output with the checksums provided by the official Anaconda website.
Just like above, if you’re able to find your checksum in the list, then the script file is safe to use and proceed with. If not, repeat the above steps to download the script again.
Step 10: Install Anaconda
After verifying the script, proceed with Anaconda installation.
- Run the script using the below command to start the installation:
bash anaconda.sh -b
Output:
Note: The above command performs a silent installation (non-interactive), which means the installer assumes that you accept the “default” settings, such as the default location and license agreement; hence, it directly installs the package.
However, if you want to specify the location path, you may use the following command to perform the installation in interactive mode:
bash anaconda.sh
2. Initialize Anaconda
If you installed the package in non-interactive mode or installed in interactive mode but entered NO
when asked for auto-initialization, then use the following command to activate Anaconda:
source <PATH_TO_CONDA>/bin/activate
If downloaded in interactive mode and entered YES
in the auto-initialization prompt, then it will get activated automatically after installation. Just refresh the bash file for changes to take effect:
source ~/.bashrc
3. Add Anaconda functions
conda init
Output:
then refresh the shell:
source ~/.bashrc
4. Verify installation
Finally, let’s confirm if the installation is complete and Ananconda is ready to use.
conda info
Output:
If you see this, it means the installation and initialization of Anaconda are successful. Now, whenever you open a new terminal, the base environment will initialize automatically, so you can start using conda
functions directly. However, if you do not want this behavior and instead prefer activating the environment manually each time before using conda
, use the below command to disable this:
conda config --set auto_activate_base False
Now, every time you want to use conda
, you should first activate the base environment using “conda activate
“, and then you are good to proceed with using conda
.
Conclusion
Installing a powerful Python library like Anaconda is a crucial step for anyone looking to power up their data science or machine learning workflows. This guide walked you through downloading, installing, and activating Anaconda to get your environment ready for efficient development. By deploying our Ubuntu server on NodeShift, we unlocked additional benefits like optimized energy consumption, scalability, and enhanced performance customized to modern workloads. NodeShift’s infrastructure ensures a smooth and reliable setup, making it the ideal choice for deploying resource-intensive tools like Anaconda in a sustainable and efficient manner.