Anaconda

From NU HPC Wiki
Jump to navigation Jump to search

Anaconda, also known as "conda," is a tool for managing Python packages. It helps you create virtual environments for different Python and package versions. You can use Anaconda to install, remove, and update packages within your project environments. For instance you can create virtual environment for game development which requires Pygame with version of Python and you can create environment for machine learning which requires Pytorch with new version of Python.

Usage: module load Anaconda3/2022.05

Working with Anaconda environments

Below is a list of main commands you should use in order to start working with Anaconda.

  1. To Check available environments, please type: conda env list
  2. View a list of packages in an environment
    • If the environment is not activated, please type: conda list -n virtualenv
    • If the environment is activated, then type: conda list
  3. Create Conda environment
    • Create an environment: conda create -n virtualenv
    • Create an environment with a specific Python version: conda create -n virtualenv python=3.12
    • Create an environment to target directory: conda create -p /shared/home/{username}/.conda/envs/virtualenv
  4. Activate an environment: source activate virtualenv
  5. Deactivate an environment: conda deactivate
  6. Remove an environment

conda remove -n virtualenv --all or conda env remove -n virtualenv

Working with packages

Install packages into virtualenv environment

  • If the environment is not activated, please type: conda --name virtualenv install PACKAGENAME
  • If the environment is activated, please type: conda install PACKAGENAME
  • If you want to install multiple packages at once: conda install pkg1 pkg2 pkg3
  • If you need to install package with specific version: conda install numpy=1.15.2

External links

Documentation

User Guide

Video

Conda Cheat Sheet