Get a list of all my environments. Active environment shown with. Conda create -name snowflakes biopython. Conda create -n snowflakes biopython. Create an environment and install program (s) conda activate snowflakes. Activate the new environment to use it. Conda deactivate. Activate a Conda environment at a particular location on disk Deactivate current environment. EXAMPLE: conda create -help CONDA 4.6 CHEAT SHEET. Conda search PKGNAME -info conda clean -all conda uninstall PKGNAME -name ENVNAME conda update -all -name ENVNAME conda install. Create environment. Conda create -n myenv conda create -n myenv python=3.6 # with a specific python version conda create -n myenv scipy # with a specific python package conda env create -f environment.yml # from a.yml file. List environments. Activate environment. Conda activate myenv. Deactivate environment.
some useful productivity tools¶¶
- code editor: sublime text: https://www.sublimetext.com/3
- nicer command line tool for Windows: http://cmder.net/
Conda commands¶¶
What is conda?
- Conda is a powerful environment and package manager.
- Create multiple environments with different versions of Python with different sets of libraries
- easily switch between environments
- http://anaconda.org/ provides free hosting for Python libraries
- conda helps to easily search for, install libraries and also to keep them up to date
Learn resources:
- getting started: http://conda.pydata.org/docs/test-drive.html#managing-environments
- reference doc: http://conda.pydata.org/docs/
List all environments¶¶
Run the above command in terminal
Create a new environment¶¶
Check if new folder was created in C:anaconda3envs
Advanced steps¶¶
Clone an existing environment¶¶
For instance, to clone the root
environment:
But you would most likely want to clone the ArcGIS Pro’s Python environment so you can experiment without messing up the default one
Starting Jupyter notebook in a different directory¶¶
For the most part you can cd
to desired directory after activating your environment and start the notebook. But if you cannot do it:
Exporting an environment to a file¶¶
It is useful to export your environment to a environment.yml
file and include it in your repository. This allows replicating the project in a different computer by you or someone else.
This creates the .yml
file with version number and source repo for all your packages. Thus, this file is specific for a particular OS and Python build version.
To create an agnostic file, use
This strips out the version numbers, enabling you to upgrade to newer versions of the packages.
Install from an environment file¶¶
To create a new environment from this file, run
Sources:
Conda Environment Cheat Sheet 2019
Package, dependency and environment management for any language
Create software environments for development and execution in a reproducible way.
For the smallest footprint, install Miniconda
,which is just the Conda package manager and Python:
Define Conda environments
Create a YAML file, e.g., my-dev-env.yml
as follows:
(default
channel listed to be explicit, can be omitted)
Create Conda environments
conda env create -f <FILENAME>
conda env create -f my-dev-env.yml
(De-)activate Conda environment
conda activate <ENV-NAME>
conda activate my-dev-env
conda deactivate my-dev-env
Search for packages
conda search <PKG-NAME>
searches whatever channels are configured (at least, that is the default
channel)
conda search --channel <CHANNEL-NAME> <PKG-NAME>
searches the packagealso in the specified channel
Add channels
conda config --add channels <CHANNEL-NAME>
Update a Conda environment
Same as: install new packages into environment.Update the YAML file, e.g.,
Update the environment: conda env update -f my-dev-env.yml
Remove an environment
conda env remove --name <ENV-NAME>
Remove package from environment
Uninstall package: conda remove --name <ENV-NAME> <PKG-NAME>
Conda Environment Cheat Sheet
Install packages via pip
Specify install command in the YAML file as follows:
For the git repo case, this installs the master branch. To install a specific branch, change as follows:
Export Conda environment specification
Why could this be important? Specifying (“pinning”) package versions prevents a change/updateof said package, BUT other packages/libraries not specifically listed in the YAML file cannevertheless be changed during conda env update
. In the worst case, this may break something.
As soon as the work performed in the Conda environment reaches a certain level ofmaturity (e.g., dependencies no longer change), one can export a more comprehensivespecification of the respective Conda environment viaconda env export --name ENV-NAME > my-dev-env.yml
. Obviously, this will overwritemy-dev-env.yml
.
Conda Create Env Cheat Sheet
Setting environment variables
Conda Environment Cheat Sheets
In the top-level directory of the Conda environment (/envs/my-dev-env/
),create the following files and folders:
Conda Environment Cheat Sheet Printable
Edit ./etc/conda/activate.d/env_vars.sh
as follows:
Edit ./etc/conda/deactivate.d/env_vars.sh
as follows:
NB: Preferred way for handling stuff such as LD_LIBRARY_PATH
etc. Microsoft remote desktop.