Example 01: Python, Numpy and Pandas Environment

Goal: Demonstrate a basic conda environment creation workflow by creating a Python environment that contains the numpy and pandas packages.


General Process

Below demonstrates the general process for:

  • Setting up your environment to use Conda via a module load.

  • How to create a conda environment.

  • How to activate/start your environment and install packages.

  • How to then use what you’ve installed.

  • And then how to deactivate/finish using your environment.

[]$ module purge []$ module load miniconda3/24.3.0 []$ conda search python []$ conda create -n py_env []$ conda activate py_env (py_env) []$ conda install python=3.12.4 (py_env) []$ python --version Python 3.12.4 (py_env) []$ conda search numpy (py_env) []$ conda install numpy (py_env) []$ python -c "import numpy; print(numpy.__version__)" 1.26.4 (py_env) []$ conda deactivate []$

Search for Packages

Conda enables you look up and search for packages and what versions are available.

[]$ conda search python Loading channels: done # Name Version Build Channel python 2.7.13 hac47a24_15 pkgs/main ... python 3.12.3 h996f2a0_1 pkgs/main python 3.12.4 h5148396_1 pkgs/main

Notice: Although Python version 2 has been deprecated, it is still used for old packages/modules/scripts. You can create a conda environment that provides this old, no longer supported version.

This is how ARCC provides this version on the cluster.


Create an Environment

[]$ conda create -n py_env Channels: - defaults Platform: linux-64 Collecting package metadata (repodata.json): done Solving environment: done ## Package Plan ## environment location: /home/salexan5/.conda/envs/py_env Proceed ([y]/n)? y

Create an Environment: Proceed


Activate an Environment


Conda Install a Version of Python

Lets check the version installed, within are active environment.


Conda Install the numpy Package

 

Lets check the version installed, within are active environment.


Conda Deactivate your Environment


(Re-)Using the Environment


Adding to an Existing Environment