Skip to content

Instantly share code, notes, and snippets.

@HariSekhon
Last active October 4, 2024 23:08
Show Gist options
  • Save HariSekhon/9b5f4792f944f53fc078ff7c95172291 to your computer and use it in GitHub Desktop.
Save HariSekhon/9b5f4792f944f53fc078ff7c95172291 to your computer and use it in GitHub Desktop.
anaconda.md from HariSekhon/Knowledge-Base repo: https://github.com/HariSekhon/Knowledge-Base

Anaconda

https://docs.anaconda.com/

Python distribution for Scientific / Maths / Data Analysis by Continuum.

Key Points

  • installs in home directory

  • binary packages available from Anaconda Cloud - can upload your own

  • select customize Anaconda installation and de-select Modify Path otherwise it'll change the bash profile

  • Anaconda appends path to .bash_profile otherwise, move to .bashrc

    • manually add ~/anaconda/bin to $PATH in .bashrc
  • removing Anaconda is simple rm -fr ~/anaconda

Anaconda Enterprise

  • Anaconda Enterprise - expensive, manages deployments across nodes
  • cheat workaround is to install open source + rsync to other nodes

Install

https://docs.anaconda.com/miniconda/

or

https://docs.anaconda.com/anaconda/install/

Add to .bashrc:

export PATH="/opt/anaconda2/bin:$PATH"
alias python="/opt/anaconda2/bin/python2.7"
conda --version
conda info

Show all environments using -e / --envs, * denotes active ones:

conda info --envs

Update conda packager manager:

conda update conda

Update packages metadata:

conda update anaconda

Adds nose package to yaml key create_default_packages in ~/.condarc, so can create new envs without package args:

conda config --add create_default_packages nose
conda config --add channels pandas

Show all config keys or specify a key:

config config --get # [<key>]

Create Environment

Create environment with biopython package in it using -n / --name:

conda create --name "$env" "$pkg"

Clone from an existing env:

conda create -n "$env2" --clone "$env"

Create another environment with specific python version 3:

conda create -n "$env" python=3 "$pkg"

Delete Environment

conda remove -n "$env" --all

Enter / Leave Environment

source activate "$env"
source deactivate

From within an env:

conda env export > py26.yml

Create new env from saved config:

conda create "$env2" -f py26.yml

Python Versions

Show available python versions using -f / --full-name:

conda search --full-name python

Packages

List installed packages in current env:

conda list

Search for package:

conda search "$pkg"

Specify -n / --name or will install in current env:

conda install [-n "$env"] "$pkg'
conda update  [-n "$env"] "$pkg"

Install from anaconda.org, search on anaconda.org and then specify specific channel's package:

conda install --channel https://conda.anaconda.org/pandas bottleneck

PIP - for stuff not available in Anaconda, activate the environment and then use pip as normal:

source activate "$env"
pip install "$pkg"

Show package was installed

conda list

Delete packages:

conda remove [-n "$env"] "$pkg" "$pkg2" ...

Search for stuff in a specific channel on https://anaconda.org:

conda search --override-channels -c pandas bottleneck

See if available from Anaconda repository:

conda search --override-channels -c defaults beautiful-soup

Build a conda package from PIP:

conda skeleton pypi "$package"
conda build "$package"

Ported from private Knowledge Base Python page 2019+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment