Conda

Create an environment

conda create -n env_name python=3.6

It is important to add python=3.6 otherwise default python command will be v2.7 and to use v3.6 (or newer) you will need to use the command python3

Good practice: always install packages in a new environment and create a new environment for a new project !

From an environment.yml: conda env create -f environment.yml

Activate environment

conda activate env_name

Return to base environment

conda deactivate

Remove an environment:

conda env remove -n env_name

List all existing environments

conda env list

List packages installed

conda list

List the packages installed in the active environment.

Be careful of duplicate install between conda and pip !

Export packages installed

YAML file for conda

conda env export > environment.yml

Exports the active environment.

This handles both pip and conda packages !

Requirements for pip

pip list --format=freeze > requirements.txt

More general since it works with pip, outside conda. There is currently an issue with pip freeze, that will include direct URL references. Using pip list --format=freeze is a good workaround (relevant stackoverflow thread)