Pre-event Material

Getting Started with Conda

Overview

Teaching: 15 min
Exercises: 0 min
Questions
  • What is Conda?

  • How do I install Conda?

Objectives
  • Get conda installed!

What is Conda?

Conda is an open source package and environment management system for any programming languages, but very popular among python community, for installing multiple versions of software packages, their dependencies and switching easily between them. It works on Linux, OS X and Windows.

Installing Miniconda

Windows

Click here to download the proper installer for your Windows platform (64 bits). We recommend to download the Python 3 version of Miniconda. You can still create Python 2 environments using the Python 3 version of Miniconda.

When installing, you will be asked if you wish to make the Anaconda Python your default Python for Windows. If you do not have any other installation that is a good option. If you want to keep multiple versions of python on your machine (e.g. ESRI-supplied python, or 64 bit versions of Anaconda), then don’t select the option to modify your path or modify your windows registry settings.

Linux and OSX

You may follow manual steps from here similar to the instructions on Windows (see above). Alternatively, you can execute these commands on a terminal shell (in this case, the bash shell):

# For MacOSX
url=https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
# For Linux
url=https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
wget $url -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
conda update conda --yes

Installing Anaconda (Optional)

NOTE: If you don’t have time or disk space for the entire distribution do not install Anaconda. Install only Miniconda, a bootstrap version of Anaconda, which contains only Python, essential packages, and conda. We will provide an environment file to install all the packages necessary for the Oceanhackweek.

Anaconda is a data science platform that comes with a lot of packages. At the core, Anaconda uses conda package management system.

List of packages included can be found here

  1. To install Anaconda, please click on the link below for your operating system, and follow the instructions on the site.
  2. Once Anaconda installation step is finished run python in the command line to test if Anaconda is installed correctly. Note: For windows, please use Anaconda prompt as the command line. It should be installed with your installation of Anaconda If Anaconda is installed correctly, you should have this prompt, which emphasizes Anaconda:
$ python
Python 3.6.4|Anaconda custom (x86_64)| (default, Jan 16 2018, 18:57:58)
...

Additional steps for Windows

If you did not add conda to the PATH environment variable during the installation, please follow the steps below to manually add conda to your PATH environment variable.

  1. Open up Anaconda Prompt and figure out the location of conda and python.
    where conda
    where python
    

    You should get the location of conda (C:\Users\lsetiawan\Miniconda3\Scripts\conda.exe) and python (C:\Users\lsetiawan\Miniconda3\python.exe)

  2. Open up Windows Command Prompt or Windows Powershell and use the SETX command to add conda to path
    SETX PATH "%PATH%;C:\Users\lsetiawan\Miniconda3\Scripts;C:\Users\lsetiawan\Miniconda3"
    

Installing Python

We will be using Python 3.6 during the week. Each tutorial will have their own conda environment that contains the correct libraries to carry out the tutorial. If you are already familiar with Python 2.7, you can take a look at the syntax differences here, but the main point to remember is to put the print statements in parentheses:

print('Hello World!')
$ conda create -n py36 python=3.6

To use Python 3.6:

$ source activate py36

To check if you have the correct version:

$ python --version

Key Points