Scripting & environments#

Python#

python3 -m venv <venv_name>
source venv_name/bin/activate

conda#

Search and find packages#

conda search <package_name>

All packages are listed here

Installing and removing packages#

Install packages with

conda install <package_name>

or from a specific channel with:

conda install --channel <channel_name> <package_name>

Install package in a specific environment:

conda install --name <env_name> <package_name>

Installed packages in current environment#

conda list

Install directly from PyPI#

In an active conda environment you can install PyPI packages using pip as normal

pip install <package_name>

Create and delete environment#

See available environments with:

conda env list

or

conda info --envs

and activate with

conda activate <env_name>

Creating a new environment with:

conda create --name <env_name>

or with a specific python version:

conda create --name <env_name> python=3.8

Delete environment with:

conda env remove --name <env_name>

Create and delete env to directory/path#

Simple enough, replace --name with --prefix.

conda env create --prefix /path/to/new/conda_env
cond env remove --prefix /path/to/new/conda_env

Save and share environments#

Dependencies can be stored in a YAML fils that can be read on all platforms (mac, win, linux):

conda env export --name ENV_NAME > env_name.yml

and to create the environment:

conda env create --file env_name.yml

Note

if there is a file named environmet.yml in your current director, you can simlply just type:

conda env create

Save with exact packages#

Save the current environment (exact) to a text file with

conda list --explicit > env_name.txt

and rebuild the exact environment with

conda env create --file env_name.txt

Warning

This will probably not work cross-platfonrm