Conda basics
| conda info | Verify conda is installed, check version number |
| conda info –env | List of install python environments |
| conda update conda | Update conda to the current version |
| conda install PACKAGENAME | Install a package included in Anaconda |
| conda update PACKAGENAME | Update any installed program |
| conda COMMANDNAME –help conda install –help | Command line help |
Using environments
| conda create –name py35 python=3.5 | Create a new environment named py35, install Python 3.5 |
| conda activate py35 | Activate the new environment to use it |
| conda env list | Get a list of all my environments, active environment is shown with * |
| conda create –clone py35 –name py35-2 | Make exact copy of an environment |
| conda list | List all packages and versions installed in active environment |
| conda list –revisions | List the history of each change to the current environment |
| conda install –revision 2 | Restore environment to a previous revision |
| conda list –explicit > bio-env.txt | Save environment to a text file |
| conda env remove –name bio-env | Delete an environment and everything in it |
| conda deactivate | Deactivate the current environment Note: Environment is already activated |
| conda env create –file bio-env.txt | Create environment from a text file |
| conda create –name bio-env biopython | Stack commands: create a new environment, name it bio-env and install the biopython package |
Finding conda packages
| conda search PACKAGENAME | Use conda to search for a package |
| https://docs.anaconda.com/anaconda/packages/pkg-docs/ | See list of all packages in Anaconda |
Installing and updating packages
| conda install jupyter | Install a new package (Jupyter Notebook) in the active environment |
| jupyter-notebook | Run an installed package (Jupyter Notebook) |
| conda install –name bio-env toolz | Install a new package (toolz) in a different environment (bio-env) |
| conda update scikit-learn | Update a package in the current environment |
| conda install –channel conda-forge boltons | Install a package (boltons) from a specific channel (conda-forge) |
| pip install boltons | Install a package directly from PyPI into the current active environment using pip |
| conda remove –name bio-env toolz boltons | Remove one or more packages (toolz, boltons) from a specific environment (bio-env) |
Managing multiple versions of Python
| conda create –name py34 python=3.4 | Install different version of Python in a new environment named py34 |
| conda activate py34 | Switch to the new environment that has a different version of Python |
| Windows: where python Linux, macOS: which -a python | Show the locations of all versions of Python that are currently in the path NOTE: The first version of Python in the list will be executed |
Specifying version numbers
Ways to specify a package version number for use with conda create or conda install commands, and in meta.yaml files.
| Constraint type | Specification | Result |
|---|---|---|
| Fuzzy | numpy=1.11 | 1.11.0, 1.11.1, 1.11.2, 1.11.18 etc. |
Exact | numpy=1.11 | 1.11.0 |
| Greater than or equal to | “numpy>=1.11” | 1.11.0 or higher |
| OR | “numpy=1.11.1|1.11.3” | 1.11.1, 1.11.3 |
| AND | “numpy>=1.8,<2” | 1.8, 1.9, not 2.0 |