Difference between revisions of "Anaconda"

From PHASTA Wiki
Jump to: navigation, search
(Add software category)
m
Line 3: Line 3:
 
This is an overview of accessing Anaconda on the viz nodes. Anaconda is a distribution of Python that includes many commonly used packages for scientific/machine-learning applications.  
 
This is an overview of accessing Anaconda on the viz nodes. Anaconda is a distribution of Python that includes many commonly used packages for scientific/machine-learning applications.  
  
It also has it's own environment manager, <code>conda</code>, which is a language-agnostic environment manager. It is used to activate access to the Anaconda packages, the Python interpreter associated with the environment, and install packages to the environment from the Anaconda public repositories. Note that installing packages through <code>conda</code> is generally preferable to <code>pip</code> as it can also install non-Python libraries that support pure Python tools (such as LAPack, BLAS, and even PETSc). Management of <code>conda</code> environments (and Python environments in general) won't be covered here (as they shouldn't be overly necessary for our purposes), but you can learn more about them at this [https://www.freecodecamp.org/news/why-you-need-python-environments-and-how-to-manage-them-with-conda-85f155f4353c/ very helpful article].
+
It also has it's own environment manager, <code>conda</code>, which is a language-agnostic environment manager. It is used to activate access to the Anaconda packages, the Python interpreter associated with the environment, and install packages to the environment from the Anaconda public repositories. Note that installing packages through <code>conda</code> is generally preferable to <code>pip</code> as it can also install non-Python libraries that support pure Python tools (such as LAPACK, BLAS, and even PETSc). Management of <code>conda</code> environments (and Python environments in general) won't be covered here (as they shouldn't be overly necessary for our purposes), but you can learn more about them at this [https://www.freecodecamp.org/news/why-you-need-python-environments-and-how-to-manage-them-with-conda-85f155f4353c/ very helpful article].
  
  

Revision as of 08:45, 25 April 2020


This is an overview of accessing Anaconda on the viz nodes. Anaconda is a distribution of Python that includes many commonly used packages for scientific/machine-learning applications.

It also has it's own environment manager, conda, which is a language-agnostic environment manager. It is used to activate access to the Anaconda packages, the Python interpreter associated with the environment, and install packages to the environment from the Anaconda public repositories. Note that installing packages through conda is generally preferable to pip as it can also install non-Python libraries that support pure Python tools (such as LAPACK, BLAS, and even PETSc). Management of conda environments (and Python environments in general) won't be covered here (as they shouldn't be overly necessary for our purposes), but you can learn more about them at this very helpful article.


Accessing Anaconda

The current (20191201) installation of the Anaconda is at /projects/tools/anaconda3. This is where Anaconda's Python interpreter is stored as well as the packages associated with it. To access this, you need to activate the conda environment.

Accessing conda

First, you need to have access to conda itself. This is done by adding the following to the .bashrc/.zshrc in you home directory:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/projects/tools/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/projects/tools/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/projects/tools/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/projects/tools/anaconda3/bin:$PATH"                                                          
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

Activating conda Environment

By default, adding the above section to your .bashrc/.zshrc will cause conda to activate the "base" environment at whenever a shell is launched.

To not have environment enabled by default (recommended to prevent inadvertent conflicts), run conda config --set auto_activate_base False. This will add a setting to the .condarc file in you home directory.

To activate a conda environment, simply run conda activate [environment name]. If the environment name is not given, it defaults to "base".

To deactivate a conda environment, simply run conda deactivate.

Official documentation on conda can be found here.


Short list of things included in Anaconda installation

  • iPython
    • Interactive Python shell
  • Jupyter
    • Offers unique interactive computing tools, namely Notebooks
    • Notebooks can be used for many different programming languages
  • Numpy
    • The fundamental scientific library
    • Offers n-dimensional array objects and functions to perform calculations with them
  • Pandas
    • Essentially numpy arrays with labels
    • Allows for easy data manipulation, plotting
    • See xarray if you're working in structured higher dimensional data
  • SciPy
    • Ecosystem of packages (including numpy, matplotlib, sympy, etc.)
    • Also a standalone package of miscellaneous scientific computing functions
  • Matplotlib
    • Matlab-style plotting package