Table of Contents#
- Prerequisites
- Step 1: Download the Anaconda Installer
- Step 2: Verify the Installer Integrity
- Step 3: Run the Anaconda Installer Script
- Step 4: Configure the Installation
- Step 5: Verify the Installation
- Step 6: Update Anaconda (Optional)
- Uninstalling Anaconda (Optional)
- Troubleshooting Common Issues
- Conclusion
- References
Prerequisites#
Before starting, ensure your system meets the following requirements:
- Ubuntu 24.04 LTS: This guide is tailored for Ubuntu 24.04, but the steps are similar for other Debian-based distributions.
- 64-bit System: Anaconda requires a 64-bit Linux OS. Verify with
uname -m(output should bex86_64). - Internet Connection: To download the installer and update packages.
- Terminal Access: You’ll need a terminal (press
Ctrl+Alt+Tto open one). - Basic Terminal Skills: Familiarity with navigating directories and running commands (we’ll guide you through specifics).
Step 1: Download the Anaconda Installer#
Anaconda provides installers for Linux on its official website. We’ll use the latest version of Anaconda3 (which includes Python 3.x, the recommended version for new projects).
Option 1: Download via the Anaconda Website#
- Open a web browser and navigate to the Anaconda Individual Edition Downloads page.
- Under “Linux,” right-click the “64-bit (x86_64)” installer link and select “Copy Link Address” to copy the download URL.
Option 2: Download via Terminal (Faster)#
For a terminal-only approach, use wget to download the installer directly. Replace <INSTALLER_URL> with the URL copied in Step 1:
wget <INSTALLER_URL>Example (replace with the latest version URL):
wget https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.shThe installer filename will follow the pattern: Anaconda3-<VERSION>-Linux-x86_64.sh.
Step 2: Verify the Installer Integrity#
To ensure the installer hasn’t been corrupted or tampered with, verify its SHA256 checksum against the official Anaconda hashes.
Step 2.1: Download the Official SHA256 Hash File#
- Visit the Anaconda Installer Hash Verification page.
- Find the SHA256 hash for your installer version (e.g.,
Anaconda3-2024.02-1-Linux-x86_64.sh) and copy it.
Step 2.2: Verify the Installer Checksum#
In the terminal, run sha256sum on the downloaded installer file to generate its checksum. Compare it to the official hash:
sha256sum Anaconda3-<VERSION>-Linux-x86_64.shExample output:
a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2 Anaconda3-2024.02-1-Linux-x86_64.sh
If the generated hash matches the official one, the installer is valid. If not, re-download the installer (corruption may have occurred during download).
Step 3: Run the Anaconda Installer Script#
Once the installer is downloaded and verified, make it executable and run the installation script.
Step 3.1: Make the Installer Executable#
In the terminal, navigate to the directory where the installer was downloaded (usually ~/Downloads):
cd ~/DownloadsMake the script executable with chmod:
chmod +x Anaconda3-<VERSION>-Linux-x86_64.shStep 3.2: Launch the Installer#
Run the installer script:
./Anaconda3-<VERSION>-Linux-x86_64.shStep 4: Configure the Installation#
The installer will guide you through setup with prompts. Follow these steps:
1. License Agreement#
- Press
Enterto scroll through the license agreement. - When prompted, type
yesand pressEnterto accept the license.
2. Install Location#
- The installer will propose a default location (e.g.,
/home/your_username/anaconda3). - To accept the default, press
Enter. - To choose a custom location, type the path (e.g.,
/opt/anaconda3) and pressEnter. Note: Custom paths may requiresudoif outside your home directory, but Anaconda recommends user-level installs.
3. Add Anaconda to PATH#
- The installer will ask: “Do you wish the installer to initialize Anaconda3 by running conda init?”
- Type
yes(recommended for new users). This adds Anaconda to your system’sPATH, allowing you to runcondaandpythoncommands directly in the terminal. - If you select
no, you’ll need to manually configurePATHlater (see Troubleshooting for details).
- Type
4. Complete Installation#
Once configuration is done, the installer will unpack and install Anaconda. This may take 5–10 minutes depending on your internet speed.
Step 5: Verify the Installation#
After installation, close and reopen your terminal to apply changes. Alternatively, refresh your terminal session with:
source ~/.bashrc # For Bash users (default on Ubuntu)
# OR
source ~/.zshrc # For Zsh users (if you use Zsh instead of Bash)Check Conda Version#
Run this command to confirm Conda is installed:
conda --versionExample output:
conda 24.3.0
Check Python Version#
Anaconda includes its own Python interpreter. Verify it with:
python --versionExample output:
Python 3.11.7
List Installed Packages#
To confirm Anaconda’s pre-installed packages (e.g., NumPy, Pandas), run:
conda listYou’ll see a list of packages with versions, confirming the installation succeeded.
Step 6: Update Anaconda (Optional)#
It’s good practice to update Anaconda immediately after installation to get the latest packages and security patches.
Update Conda#
First, update the Conda package manager itself:
conda update condaType yes when prompted to proceed with updates.
Update All Packages#
Next, update all Anaconda packages to their latest versions:
conda update anacondaAgain, type yes to confirm.
Uninstalling Anaconda (Optional)#
If you need to remove Anaconda later, follow these steps:
1. Delete the Anaconda Directory#
Remove the Anaconda installation folder (replace ~/anaconda3 with your custom path if used):
rm -rf ~/anaconda32. Remove Conda Initialization from Shell Configuration#
Anaconda adds initialization code to your shell config file (e.g., ~/.bashrc, ~/.zshrc). To clean this up:
-
Open the config file in a text editor (e.g.,
nano):nano ~/.bashrc -
Scroll to the bottom and delete all lines between
# >>> conda initialize >>>and# <<< conda initialize <<<. -
Save and exit: Press
Ctrl+O, thenEnter, thenCtrl+X.
3. Refresh the Terminal#
Apply changes by restarting the terminal or running:
source ~/.bashrcTroubleshooting Common Issues#
Issue: “conda: command not found”#
If conda isn’t recognized after installation, Anaconda wasn’t added to PATH. Fix this by:
- Opening your shell config file:
nano ~/.bashrc - Adding this line at the bottom (replace
your_usernamewith your actual username):export PATH="/home/your_username/anaconda3/bin:$PATH" - Save, exit, and refresh:
source ~/.bashrc
Issue: Permission Errors During Installation#
If you see Permission denied, you likely tried to install Anaconda in a system directory (e.g., /usr/local) without sudo. Instead, install in your home directory (default) or use sudo with caution:
sudo ./Anaconda3-<VERSION>-Linux-x86_64.shIssue: 32-bit vs. 64-bit Mismatch#
If the installer fails with invalid ELF header, you downloaded the 32-bit installer by mistake. Ensure you use the 64-bit (x86_64) installer for Ubuntu 24.04.
Conclusion#
You’ve successfully installed Anaconda on Ubuntu 24.04! Anaconda provides a robust, pre-configured environment for data science, with tools like Conda for package management and Python for scripting.
Next steps:
- Create isolated environments with
conda create --name myenv python=3.11(replacemyenvwith your environment name). - Install additional packages with
conda install package_name. - Explore Anaconda Navigator (a GUI) by running
anaconda-navigatorin the terminal.