Skip to content

Creating Your First Conda Environment

First, enable the conda command. We recommend adding this to your .bashrc file so it happens automatically every time you log in:

Using your favorite text editor, open the .bashrc file:

vi ~/.bashrc
Once in the text editor, move your cursor to the to the bottom of the page and press the letter o. Paste the following line, then press Esc to exit insert mode.

source /optnfs/common/miniconda3/etc/profile.d/conda.sh

Now save and quit with:

:wq

There is a bug in the conda command that requires a one-time workaround. If you already have a .conda directory in your home, you can skip this step -- but it won't hurt anything if you run it again:

mkdir -p .conda/pkgs/cache .conda/envs

Creating an Environment

When creating a Python environment, it's common to specify the Python version at creation time. Use the conda create command with the python= argument. Versions can be specified as:

  • Nothing: In this case, you'll get the latest version of Python available in the Conda repository.
  • A major version (e.g., 2 or 3): You'll get the latest available release of that major version.
  • A specific version (e.g., 3.4.3): You'll get exactly that version.

You can also include additional packages during creation. For example, the following command creates an environment named discovery_class with Python 3.9.5 and the latest version of numpy:

conda create --name discovery_class python=3.9.5 numpy

Activating the Environment

[john@andes8 discovery]$ conda activate discovery_class

To verify we are using the new version of python we can run python -V

(mytest) [john@andes discovery_class_website]$ python -V
Python 3.9.5