Basic Tutorials Part 3

Sanyam Bhutani
AI Saturdays
Published in
3 min readDec 22, 2017

Conda

You can find me on Twitter @bhutanisanyam1

This Post first appeared Here

Overview:

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.

Another point worth mentioning is, Open Source projects share their ‘source’ code; which needs to be compiled everytime you want to use it. However, compiling a huge library can be tedious and time taking. Conda provides precompiled libraries to be downloaded whenever you need to install something new. So you just have to download it and can dive right in!

A detailed tutorial of using Conda and Jupyter notebooks will be shared in Part-1 of this series.

Package Managers

Package managers are used to install libraries and other software on your computer. Pip is the default package manager for Python libraries.

Conda is similar to pip except that the available packages are focused around data science while pip is for general use.

However, conda is not Python specific like pip is, it can also install non-Python packages but it does include all the Python packages and supports pip.

Environments

While creating a Project, you will require various libraries and dependencies. Some projects will require a certain set of libraries which will work only with a given version of a set of other libraries, but at the same point you might want to work on a different set of projects.

To help with this, Conda creates separate ‘environments’. A environment X with a set of libraries is independent and unaffected by another environment Y. Thus you can work on your given projects without worrying about ‘breaking’ the requirements everytime you install something-when you do, conda ensures that the ‘environment’ works in cohesion by changing other libraries.

Packages

Conda is the package of Anaconda. If you’ve used virtual env, pip: it includes both of these functionalities along with a few extra.

We will use conda because we’re geeks. Just kidding, conda will be required when you need to access a cloud instance since you won’t have access to GUI. Plus, it’s easier to type 1 command than click a few buttons (Okay, maybe I wasn’t kidding about the geekiness).

Installation

Anaconda navigator which serves as a GUI to the Conda package and includes it is supported on Linux, OS X and Windows.

You can download the Navigator from Here

Select your OS and follow the Steps. These are pretty basic and have been omitted. If you’re stuck anywhere or need help, please ask us in the comments below.

Tutorials

The commands below are to serve as a syntax. We’ve create a Github repository for you to use. Feel free to use the code from there

Github repository link (Link to be updated soon)

  • Creating an environment:
conda create -n env_name list of packages
  • Using an environment

To use an environment:

source activate envnameWindows: actiavte envname

Notice that your prompt has a (envname) before it.

To get out of an environment:

source deactivate
  • To install packages
source activate envname
conda install packagename
  • Sharing requirements:

Your project has a certain set of required libraries in order to work. When sharing your project, you share your requirements file so that one can create an environment directly from these.

conda env export > environment.yaml

This creates a YAML file that contains the list of dependencies of the project.

  • To create an environment using a YAML file:
conda env create -f environment.yaml

This creates a new environment with the name as is — inside the YAML file.

  • To remove an environment
conda env remove -n env_name
  • To list all the environments inside your machine
conda env list

This is by no means an exhaustive list of the commands. These are meant to serve for an introductory purposes.

Checkout the Conda user guides if you want to learn more.

Here is another interesting read Common Myths and Misconceptions

Leave us a comment below if there is anything you want to discuss

Subscribe to Init27’s NewsLetter for a Weekly-ish curated reads on Deep Learning and Computer Vision

--

--

Sanyam Bhutani
AI Saturdays

Machine Learning Engineer and AI Content Creator at H2O.ai, Fast.ai Fellow, Kaggle x3 Expert (Ranked in Top 1%), Twitter: https://twitter.com/bhutanisanyam1