DEV Community

Cover image for GETTING STARTED WITH CONDA
SAI GOUTHAM
SAI GOUTHAM

Posted on • Originally published at Medium

GETTING STARTED WITH CONDA

What will you learn from reading this article?

  • ๐Ÿ“Œ About Anaconda
  • ๐Ÿ“Œ Installing Anaconda in your Computer
  • ๐Ÿ“Œ About Conda package
  • ๐Ÿ“Œ What are Conda Environments
  • ๐Ÿ“Œ working with Anaconda Prompt / Terminal
  • ๐Ÿ“Œ Setting up Conda Environments
  • ๐Ÿ“Œ The 10 basic Syntaxes to Master the Conda Environment Setup

Lets get Started


We all know that Anaconda is the very popular amongst Data Scientists, python Programmers, etc. This Article helps you with getting started with Conda and setting up Anaconda in your PC. This article also helps you with Setting up Environments in your PC using Anaconda.

What is Anaconda?


Wikipedia says that - Anaconda is a distribution of the Python and R programming languages for scientific computing (data science, machine learning applications, large-scale data processing, predictive analytics, etc.), that aims to simplify package management and deployment. The distribution includes data-science packages suitable for Windows, Linux, and macOS. It is developed and maintained by Anaconda, Inc., which was founded by Peter Wang and Travis Oliphant in 2012. As an Anaconda, Inc. product, it is also known as Anaconda Distribution or Anaconda Individual Edition, while other products from the company are Anaconda Team Edition and Anaconda Enterprise Edition, both of which are not free.

Why Anaconda?

  • Conda has very wide set of Packages for python programming which makes coding simpler compared. Anaconda packages keeps on getting updated constantly as well.
  • Anaconda also comes with several IDE's and Text Editors like, Pycharm, Sypder, Jupyter notebook, etc., Leaving the user to choose on which platform does he wants to code upon.
  • The UI is pretty smooth and good.
  • It has a separate app called Anaconda Navigator which is really helpful to keep track of all our your installed libraries, packages and their updated versions, Conda - Installed text editors / IDE.
  • It also comes with R - Studio. (you need to install it from the anaconda Navigator).
  • The best part of Anaconda is it comes with Anaconda Prompt, through which we can install libraries, packages, dependencies, etc., with easy bash commands. (it might not be anything interesting for Linux/Mac OS users but when it comes to windows users, they suffer a lot with the power shell being used in the command line which is slightly different from Terminal.)

How to Setup Anaconda in Your PC?


Step :1 Go to Anaconda Site - https://www.anaconda.com/
Visit The Anaconda website Login if you want to. Then Click on Get Started.

Step :2 Download Anaconda for your PC based on Your OS
Click on the download Anaconda Installers and select your OS.

Step :3 Install Anaconda
After the file gets downloaded, Install it. The installation Process will be pretty simple. This might take some time so have a cup of Tea and Come back.

THE CONDA PACKAGE

Anaconda official website documentation about Conda Says that - Conda is an open-source package management system and environment management system that runs on Windows, macOS, and Linux. Conda quickly installs, runs, and updates packages and their dependencies. Conda easily creates, saves, loads, and switches between environments on your local computer. It was created for Python programs but it can package and distribute software for any language.

In its default configuration, Conda can install and manage the over 7,500 packages at repo.anaconda.com that are built, reviewed, and maintained by Anacondaยฎ.

โš™ Setting Up the Environments in Anaconda!

So many people doesn't understand the purpose of creating Environments and how to create the work environment in anaconda.

โ“But Why to setup an environment?

  1. Setting up your own work environment is necessary because you cant keep track of every single package as there are multiple packages which keeps or suggests updating on regular basis. So some programs doesn't work if they have done in older package version and run after the package got updated. So in such case instead of avoiding of installing and reinstalling the packages you can simple create a work environment of that version of the package and run the program in that environment every time which is pretty cool and time saving.
  2. Environments are highly useful especially when you are working as a team. When you are working as a team its not possible that every package that you and your friends have are of same versions. So sometimes code may not get executed properly due to the difference of the packages versions. In such cases you can clone / import your friends Environment into your PCs and work on the project without any problems.
  3. The good thing about Conda is, it keeps all the history of the changes that you make so you can easily roll back if you wanted the previous version of it.

Note: MAC/LINUX Users use the terminal and Windows users use Anaconda Prompt for the following steps:

1๏ธโƒฃ CREATING THE ENVIRONMENTS

  1. Creating a New Environment:
conda create --name myenv
Enter fullscreen mode Exit fullscreen mode

โœ… When conda asks you to proceed, typeย y:

proceed ([y]/n)?

This creates the myenv environment inย /envs/. No packages will be installed in this environment.

  1. Creating an Environment with Specific Version of Python:
conda create -n myenv python=3.6
Enter fullscreen mode Exit fullscreen mode
  1. Creating an environment with a specific package:
conda create -n myenv scikit-learn
Enter fullscreen mode Exit fullscreen mode
                           (OR)
Enter fullscreen mode Exit fullscreen mode
conda create -n myenv python
conda install -n myenv scikit-learn
Enter fullscreen mode Exit fullscreen mode
  1. Creating environment with a specific version of a package:
conda create -n myenv scipy=0.15.0    
Enter fullscreen mode Exit fullscreen mode
                       (OR)
Enter fullscreen mode Exit fullscreen mode
conda create -n myenv python
conda install -n myenv scipy=0.15.0
Enter fullscreen mode Exit fullscreen mode
  1. Creating environment with a specific version of Python and multiple packages:
conda create -n myenv python=3.6 scipy=0.15.0 astroid babel
Enter fullscreen mode Exit fullscreen mode

myenv - basically your environment name .

๐Ÿ’ก TIP:

These are the basic ways to creating an environment. However You can do much more with conda create command. For details, runย condaย createย --help.

2๏ธโƒฃ ACTIVATING THE ENVIRONMENTS

  • You can Activate the conda Environment by typing the below code:
conda activate myenv
Enter fullscreen mode Exit fullscreen mode

myenv - basically your environment name

3๏ธโƒฃ DEACTIVATING THE ENVIRONMENTS

  • You can Deactivate the conda Environment by typing the below code:
conda deactivate
Enter fullscreen mode Exit fullscreen mode

4๏ธโƒฃ CLONING THE ENVIRONMENTS

  • You can Clone your exact conda Environment by typing the below code:
conda create --name myclone --clone myenv
Enter fullscreen mode Exit fullscreen mode

myclone - basically the name of clone environment

myenv - name of the environment that you want to clone

5๏ธโƒฃ LISTING THE ENVIRONMENTS

  • basically you can view the number of existing environments that are in your PC by typing the following code:
conda env list
Enter fullscreen mode Exit fullscreen mode
           (OR)
Enter fullscreen mode Exit fullscreen mode
conda info --envs
Enter fullscreen mode Exit fullscreen mode

6๏ธโƒฃ SHARING THE ENVIRONMENTS

  • You can share your environments with your friends or Team mates by typing the following code:
conda env export > environment.yml
Enter fullscreen mode Exit fullscreen mode

Share the environment.yml file with the person whom who wanted to share.

7๏ธโƒฃ INSTALLING THE SHARED ENVIRONMENTS

  • You can Install the shared environments from your friends or Team mates by typing the following code:
conda env create -f environment.yml
Enter fullscreen mode Exit fullscreen mode

8๏ธโƒฃ REMOVING / DELETING THE ENVIRONMENTS

  • You can remove or delete the environment by typing the following code:
conda remove --name myenv --all
Enter fullscreen mode Exit fullscreen mode

9๏ธโƒฃ RESTORING ENVIRONMENTS

  • The good thing about Conda is, it keeps all the history of the changes that you make so you can easily roll back if you wanted the previous version of it.
  • You can restore the deleted environments by using the following code:
conda list --revisions
Enter fullscreen mode Exit fullscreen mode

Then make a note of that REVNUM

conda install --revision=REVNUM
Enter fullscreen mode Exit fullscreen mode
                     (OR)
Enter fullscreen mode Exit fullscreen mode
conda install --rev REVNUM
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”Ÿ USING PIP COMMAND IN ENVIRONMENTS

  • This is not a necessary command we don't use it all the time to install the packages or etc., but knowing about pip is definitely important.
conda install -n myenv pip
conda activate myenv
pip install streamlit
Enter fullscreen mode Exit fullscreen mode

This sums up the basic things about Anaconda, Its installation and Environments. How ever you can refer to the official website of Anaconda and check its documentation if you want to dive deeply into it or to know more about it.

๐ŸŒ Anaconda Official Site: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#

โžก There is a video about the the same in a youtube channel Data Professor. He explained neatly within the code editor lively. I highly recommend you to watch the video if you want to have visual explanation about the basic things about the Conda

๐ŸŽฅ Data Professor Youtube Channel @data PROFESSOR: https://youtu.be/sDCtY9Z1bqE


Author:

K. SAI GOUTHAM

If you have found value through this article consider supporting me. Cheers!

โœจ My Git Hub - Follow me on Git Hub and Visit My Github for Python and Data Science Related Projects.

โœจ MEDIUM - Follow me on medium for my articles

โœจ My Linkedin - You can connect with me through linkedin

โœจ Patreon - You can Follow me and Support Me by contributing to my patreon

Thank You for visiting my article. ๐Ÿ‘‹๐Ÿป
Enter fullscreen mode Exit fullscreen mode

Top comments (0)