1.2. Option #2 – Conda package manager¶
1.2.1. Installing miniconda and external packages¶
Note
If you are using the pre-built CODAS Virtual Computer, you can skip this step.
This section describes the installation of a conda environment on an intel computer (Mac or Linux), to provide Matplotlib, Numpy, and other third-party code. You still need to install CODAS software after this step.
Note
If you are running a newer Mac (M1 or M2 chip),
Download this yaml file codas_processing_m1-m2.yml
and
this text file M1-M2_install_steps.txt
with slightly different
instructions. Substitute the instructions in that text file and skip the rest
of this page. We’ll make it prettier later.
The instructions on this page for installing conda are specific to an INTEL MAC and have been tested on Xubuntu 20.04 Linux host, but most of the steps will be similar on other machines. Some notes about other platforms are included.
The instructions also assume that you are installing most things from scratch; if you have remnants of earlier installations or attempts, conflicts could occur, and these can be very confusing and difficult to track down.
Instructions for conda installation change about every 6-12 months. If you run into trouble, contact us at uhdas@hawaii.edu.
(1) Install Miniconda
Miniconda is the name of the minimalist installer for a base environment with the conda package manager. Our strategy is to install this base environment and then use it to create a working environment in which we will install the CODAS dependencies using conda, before installing the CODAS packages from our Mercurial repositories.
To begin, install the latest Python 3, 64-bit version of Miniconda that matches your operating system.
Download and install the conda package manager:
Download the Miniconda installer (eg.
Miniconda3-latest-Linux-x86_64.sh
)Find it, then run this (or equivalent) in your commandline terminal window:
bash Miniconda3-latest-Linux-x86_64.sh
(At the time of this writing, the script must be run using
bash
, even though the intent was that it be executable withsh
.)Scroll to the bottom of the license agreement and enter
yes
to accept it.Accept the default installation location, which will be
minicoda3
in your home directory.When asked:
Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no]
choose No.
Execute the initialization:
The installer has now finished, leaving you back at the command line in your terminal window. Run this command:
~/miniconda3/bin/conda init --all
This will list many configuration and startup files, and show you which ones it changed. By running this initialization manually we are able to include the
--all
option, which initializes all shells; if you change your default shell in the future, conda will still work.Prior to this, when the installer finished, you might have noticed the line:
==> For changes to take effect, close and re-open your current shell. <==
Do this now!
On Linux, close your terminal window and open another one.
On MacOS, you need to completely quit the terminal application (Terminal or iTerm) and restart it.
(Here, “shell” is referring to the command interpreter, usually bash or zsh, that is running inside the terminal window. We need to start a new one to get the effect of the
conda init
step that you just took.)
Also at the end of the installation text you may have seen:
If you'd prefer that conda's base environment not be activated on startup, set the auto_activate_base parameter to false: conda config --set auto_activate_base false
It’s wise to start outside any environment and explicitly select the one you want. Therefore, in your new terminal (so that the conda command will be found) execute:
conda config --set auto_activate_base false
Now start a new shell as before and if the prompt says this:
codaspy:(~)$
you are all set.
We also want to configure conda to get packages from conda-forge, so execute these two commands:
conda config --add channels conda-forge conda config --set channel_priority strict
See https://conda-forge.org/docs/ for more information.
Now that the conda configuration options have been set, again start a new shell as before, simply with a new terminal window on Linux, or quitting and restarting your terminal application on MacOS.
(2) Install conda packages
In your new terminal you should see your normal prompt, with no indication that you are in a conda environment, but the conda command should be available. You can check by executing:
which conda
Depending on the shell you are running, it should return either a path that
starts with your home directory followed by miniconda3/condabin/conda
(if
running bash), or multiple lines of shell code defining a conda
function
(if running zsh).
Download codas_processing_intel.yml
, and run the following command:
conda env create --file codas_processing_intel.yml
You have created your main working environment, called pycodas
. To use it,
you have to activate it in your terminal window (or shell) with:
conda activate pycodas
Now you will see that your command prompt includes (pycodas)
To deactivate it you can use:
conda deactivate
but most likely you won’t need to do this.
Note
Every time you want to use the new environment in a new terminal window, be sure to execute:
conda activate pycodas
If you want your terminal window to always start in this environment you can append this command to the appropriate shell configuration file.
(4) Install a C compiler (OS X only)
For OSX, you will need the Apple C compiler. You can get it on line by installing all of Xcode (it’s huge), and then the command-line tools, or you can just install the latter directly. To get the command-line tools alone (recommended), invoke:
xcode-select --install
On our recommended Linux distribution, the C compiler (gcc) is installed by default.
(6) Install CODAS software
Now you are ready to install CODAS software.