- 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 Ubuntu 18.04 and 20.04?
Anaconda is an open-source distribution of Python and R programming languages used for data science, machine learning, and artificial intelligence projects. It comes with various pre-installed libraries and packages that are useful for scientific computing, data analysis, and data visualization. In this article, we will walk through steps to install Anaconda on Ubuntu 18.04 and 20.04.
Prerequisites
Before installing Anaconda on Ubuntu 18.04 or 20.04, you should have access to a terminal window or command-line interface with superuser privileges.
Step 1: Download Anaconda
The first step is to download Anaconda installation file from official Anaconda website. To download Anaconda, open your web browser and navigate to following URL: https://www.anaconda.com/products/individual.
On Anaconda individual edition page, scroll down until you see Linux section, and click on download button for appropriate version of Anaconda for your system.
Step 2: Install Anaconda
Once download is complete, navigate to directory where you saved Anaconda installation file using terminal or command-line interface.
For example, if you saved file in Downloads folder, use following command −
cd ~/Downloads
Next, make Anaconda installation file executable by running following command −
chmod +x Anaconda3-2021.05-Linux-x86_64.sh
Note that version number may vary depending on version you downloaded. You should replace "Anaconda3-2021.05-Linux-x86_64.sh" with actual filename of installation file you downloaded.
Now, run following command to start Anaconda installation −
./Anaconda3-2021.05-Linux-x86_64.sh
Again, replace version number with actual filename of installation file you downloaded.
Step 3: Follow Installation Wizard
After running above command, you will be prompted to agree to Anaconda license agreement. Type "yes" and press Enter to continue.
Next, you will be asked to choose installation location. default location is usually best option, so simply press Enter to proceed.
You will also be asked if you want to add Anaconda to your PATH. It's recommended to say yes, so you can easily run Anaconda from terminal. Type "yes" and press Enter to continue.
Finally, installation wizard will ask if you want to install Visual Studio Code. If you already have a preferred code editor, you can skip this step by typing "no" and pressing Enter.
Once installation is complete, you can activate Anaconda environment by running following command −
source ~/.bashrc
This will add Anaconda path to your system's PATH variable, allowing you to run Anaconda commands from terminal.
Step 4: Test Installation
To test installation, open a new terminal window and type following command −
conda list
This will display a list of all packages and libraries installed by default with Anaconda.
Congratulations! You have successfully installed Anaconda on Ubuntu 18.04 or 20.04. You can now start using Anaconda to develop your data science, machine learning, and artificial intelligence projects.
Step 5: Create and Activate an Environment
Anaconda allows you to create isolated environments where you can install specific versions of packages and libraries. This is useful when you need to work on different projects with different requirements. To create a new environment, use following command −
conda create --name myenv
Replace "myenv" with name you want to give to your environment. You can also specify version of Python or any other packages you want to install in this environment.
To activate environment, run following command −
conda activate myenv
Now, any packages or libraries you install will be installed in this environment.
Step 6: Install Packages and Libraries
Anaconda comes with many pre-installed packages and libraries, but you may need to install additional ones depending on your project requirements. To install a package or library, use following command −
conda install package_name
Replace "package_name" with name of package you want to install. You can also specify version number or any other dependencies you want to install along with package.
Step 7: Update Anaconda
It's a good practice to keep your Anaconda installation up-to-date with latest packages and libraries. To update Anaconda, use following command −
conda update anaconda
This will update all packages and libraries installed by default with Anaconda. You can also update individual packages by specifying their names.
Step 8: Uninstall Anaconda
If you want to uninstall Anaconda from your system, you can do so by running following command −
rm -rf ~/anaconda3
This will remove Anaconda installation directory from your system.
Step 9: Using Jupyter Notebook
Jupyter Notebook is a popular web application used for data analysis, data visualization, and machine learning. It allows you to write and run code in a web-based environment, making it easy to share and collaborate on projects. Anaconda comes with Jupyter Notebook pre-installed, so you can start using it right away.
To launch Jupyter Notebook, activate your Anaconda environment and run following command −
jupyter notebook
This will open a new tab in your web browser with Jupyter Notebook interface. From here, you can create new notebooks, open existing ones, and run code cells.
Step 10: Using Conda Virtual Environments
Anaconda also comes with a package manager called Conda. Conda allows you to manage packages and dependencies for different projects, just like virtual environments in Python. You can create and manage virtual environments using Conda by running following commands −
To create a new virtual environment −
conda create --name env_name
To activate virtual environment −
conda activate env_name
To deactivate virtual environment −
conda deactivate
To list all available virtual environments −
conda env list
To delete a virtual environment −
conda env remove --name env_name
Step 11: Installing Packages with Pip
While Conda is a great package manager for Python packages, there may be times when you need to install packages with pip, default Python package manager. To install packages with pip in your Anaconda environment, you can use following command −
pip install package_name
Replace "package_name" with name of package you want to install. You can also specify version number or any other dependencies you want to install along with package.
Step 12: Creating and Exporting an Environment
If you have installed a lot of packages and libraries in your Anaconda environment, you may want to create an environment file to keep track of all dependencies. You can create an environment file using following command −
conda env export > environment.yml
This will create a file called "environment.yml" in your current directory, containing all packages and dependencies installed in your current environment.
To create a new environment using environment file, use following command −
conda env create -f environment.yml
This will create a new environment with same packages and dependencies as one specified in environment file.
Step 13: Sharing your Environment
If you want to share your Anaconda environment with others, you can export environment file and share it with them. They can then create a new environment using environment file and have same packages and dependencies as you.
To export your environment, use following command −
conda env export > environment.yml
Then, share "environment.yml" file with others. They can then create a new environment using following command −
conda env create -f environment.yml
Conclusion
In this article, we have walked through steps to install Anaconda on Ubuntu 18.04 and 20.04. We have also covered how to create and activate environments, install packages and libraries, update Anaconda, and uninstall Anaconda from your system. With these steps, you should now be able to start using Anaconda for your data science, machine learning, and artificial intelligence projects.