To create an environment named py37
with python 3.7, using the channel conda-forge and a list of packages:
conda create -y --name py37 python=3.7
conda install --force-reinstall -y -q --name py37 -c conda-forge --file requirements.txt
conda activate py37
...
conda deactivate
Flags explained:
-y
: Do not ask for confirmation.
--force-reinstall
: Install the package even if it already exists.
-q
: Do not display progress bar.
-c
: Additional channel to search for packages. These are URLs searched in the order
Alternatively you can create an environment.yml file instead of requirements.txt:
name: py37
channels:
- conda-forge
dependencies:
- python=3.7
- numpy=1.9.*
- pandas
Use these commands to create and activate the conda environment based on the specifications in the Yaml file:
conda env create -f environment.yml
conda activate py37
Use this command to list the environments you have:
conda info --envs
Use this command to remove the environment:
conda env remove -n py37
New! The ansible-role dockpack.base_conda can manage conda environments on Linux, Mac and Windows, and can be used to create a docker image with custom conda environments.