Conda Environment Cheat Sheet



Conda Enjoy this cheat sheet at its fullest within Dash, the macOS documentation browser. Update conda package and environment manager. Conda update anaconda. To restore environment to a previous revision: conda install-revision=REVNUM or conda install-rev REVNUM. PDF CONDA CHEAT SHEET, Delete an environment and everything in it. Deactivate the current environment. Create environment from a text file. Stack commands: create a new environment, First you have to deactivate your environment before.

Conda cheat sheet
Environment
//
# Deactivating the activation of the base environment in Python:
conda config --set auto_activate_base false
//
**Listing all installed packages
conda list
//
#To install a package
conda install packagename
#To install a package from a certain channel
conda install -c bioconda pybedtools
#To uninstall (deinstall) a certain package
conda uninstall packagename
#We can upgrage packages:
conda update numpy
#Verify environment we are right now:
conda info --envs
#create a new environment with some packages installed
conda create --name bamqc numpy pandas
#activate the created environment
source activate bamqc
#deactivate the environment
source deactivate
#installing a new environment with a new python version:
conda create --name blahblah python=2.7
#installing a new version with all python packages included in anaconda
conda create -n python2.7_env python=2.7 anaconda
#list all envs
conda env list
#remove a given env
conda env remove --name bamqc
#setting the environment variables for a specific environment:
#Read useful post:
http://www.benjaminmgross.com/conda-env-vars/
1)
$ echo $PATH
/home/benjaminmgross/anaconda/envs/my_env/
2)
$ cd PATH
$ mkdir -p ./etc/conda/activate.d
$ mkdir -p ./etc/conda/deactivate.d
3)
$ touch ./etc/conda/activate.d/env_vars.sh
$ touch ./etc/conda/deactivate.d/env_vars.sh
4)
./etc/conda/activate.d/env_vars.sh <File>
#!/bin/sh
export MY_KEY='secret-key-value'
export MY_FILE=/path/to/my/file/
5)
./etc/conda/deactivate.d/env_vars.sh <File>
#!/bin/sh
unset MY_KEY
unset MY_FILE
#activating table of contents in jupyter:
Install extensions from:
https://github.com/ipython-contrib/jupyter_contrib_nbextensions
#opening jupyter notebook on a particular working dir:
jupyter notebook --notebook-dir=/Users/yourname/folder1/folder2/
#Enter in the command mode (gray box with blue edges) and enter with ESC
# Select cells downwards:
shift+down_arrow
# Python markdown
This nbextension allows to display output generated by the kernel in Markdown cells
For example: If you set variable a in Python
a = 1.23
and write the following line in a markdown cell:
a is {{a}}
It will be displayed as:
a is 1.23
//
#save to a file all packages in an environment:
conda list --export > packages.env
#Then we can use this file to create a new environment:
$ conda create -n ch1env --file packages.env
//
*Saving an entire environment to a file:
conda env export --file env.yml
/
*Now, we can create the environment from the env.yml file:
conda env create -f environment.yml
//
#having info on the conda we have:
conda info
# especially important are the channels, because it conditions what programs are available
//
#adding bioconda channels
#The first one is optional and the order is important
(conda config --add channels r)
conda config --add channels defaults
conda config --add channels conda-forge
conda config --add channels bioconda
#Now we can install one the bioconda programs, like for example bwa:
conda install bwa
//
* Creating an environment from a yaml file:
conda env create -f environment.yml
And the contents of environment.yml is:
name: stats
dependencies:
- python=3.4
- numpy
- pandas
# create env with R and some certain basic packages
$ conda create -n r_env r-essentials r-base
# How do I prevent Conda from activating the base environment by default?
conda config --set auto_activate_base false
The first time you run it, it'll create a ./condarc in your home directory with that setting to override the default.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Here we will explain how to install pytorch with conda.

Downloading

You can choose right version for your system fromhttps://docs.conda.io/en/latest/miniconda.html.

Windows users should follow the tutorial fromhttps://docs.conda.io/projects/conda/en/latest/user-guide/install/windows.html.

Conda Environment Cheat Sheet

Linux users can run the following script:

In terminal execute the following line:

Mac users can also run the same script changing
Miniconda3-latest-Linux-x86_64.sh intoMiniconda3-latest-MacOSX-x86_64.sh.

2019

Adding conda to PATH (Mac and Linux)

Then add conda to $PATH by running

2019

If you do not want to run it each time you start the system you can add this line to ~/.bashrc(or .zshrc). For example by calling

(Mac.zshrc) and adding these lines at the end of the file. Then run

Update conda (all platforms)

Creating and activating environment

Conda Create Environment Cheat Sheet

You can deactivate it with source deactive. More info on https://conda.io/docs/user-guide/tasks/manage-environments.html

Environment

Conda Create Env Cheat Sheet

Installing pytorch (with numpy, jupyter and matplotlib)

Install other useful packages

Run jupyter and test it

After activating environment run

Conda Environment Cheat Sheet

When the web page opens, click on button “New”, choose “Python 3”.

Conda Create Environment Cheat Sheet

Then copy the following into the cell and press Control+Enter. Change imgs/shelf.JPG to any image of your coice.

Conda Environment Cheat Sheet Printable

Updated: 2020-02-02