Installing Conda Distribution


In the previous section, we described multiple Python libraries commonly used for earth science analysis. In this section, we will show how to install these tools.

Installing the Default Conda Distribution

First, we need to install the default Conda distribution. Conda is a powerful package manager that simplifies the installation and management of software packages and environments. You can install the default Conda distribution (Anaconda or Miniconda) by following these steps:

Download and Install Anaconda or Miniconda:

Visit the Anaconda Distribution page to download the Anaconda installer, which includes a wide array of data science packages.

Alternatively, if you prefer a minimal installation, download the Miniconda installer, which includes only Conda and its dependencies.

Install Conda:

Follow the installation instructions for your operating system. For example, on macOS or Linux, you can install Miniconda with the following command in the terminal:
bash

1
bash Miniconda3-latest-MacOSX-x86_64.sh

Verify Installation:

After installation, you can verify Conda is installed correctly by running:

1
conda --version

Creating a Conda Forge Environment

For some Python libraries, it is better to use the Conda Forge channel, which is a community-driven collection of packages for Conda. For example, on macOS, installing TensorFlow might require using the Conda Forge channel. Here’s how to create a Conda environment using Conda Forge:

Create a New Environment:

Use the following command to create a new environment named earth_sci_env with Conda Forge as the priority channel:

1
conda create -n earth_sci_env -c conda-forge python=3.9

Activate the Environment:

Once the environment is created, activate it using:

1
conda activate earth_sci_env

Install Packages:

Install necessary packages within this environment. For example, to install TensorFlow, run:

1
conda install -c conda-forge tensorflow

It is crucial not to mix packages from the default Conda channel and the Conda Forge channel within the same environment, as this can lead to dependency conflicts and errors.

DigitalOcean

For deploying applications and managing servers, DigitalOcean is a popular cloud service provider. Personally, I have used DigitalOcean to set up virtual servers for running earth science analysis. You can easily create and manage virtual machines (Droplets) and use them for hosting your applications.

Creating a Docker Container

To share your work and ensure consistency across different environments, creating a Docker container is a practical solution. Docker allows you to package your applications and their dependencies into a container that can run anywhere. Here’s how to create a Docker container for your earth science analysis tools:

Install Docker:

Download and install Docker from the official Docker website.

Create a Dockerfile:

Write a Dockerfile to specify the environment and dependencies. Here is an example Dockerfile:
dockerfile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
FROM continuumio/miniconda3

# Create a new conda environment
RUN conda create -n earth_sci_env -c conda-forge python=3.9

# Activate the environment and install necessary packages
RUN /bin/bash -c "source activate earth_sci_env && \
    conda install -c conda-forge numpy pandas matplotlib tensorflow"

# Set the default command to run when starting the container
CMD ["bash"]

Build and Run the Docker Container:

Build the Docker image using the Dockerfile:

1
docker build -t earth_sci_image .

Run a container from the image:

1
docker run -it earth_sci_image

Using Docker ensures that your analysis environment is reproducible and portable, allowing you to share your work effortlessly with colleagues or across different systems.

By following these steps, you will have all the necessary tools installed and ready for your earth science analysis tasks.