Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conda create env from file - How to specify prefix in the file?

I read that the prefix line in the environment.yaml file is not used by conda env create. Two of the posts on SO pointing to this fact are:

export conda environment without prefix variable which shows local path to executable

Anaconda export Environment file

I have the reverse problem of most of these posts

I want to specify inside the file the actual prefix, so that different users setup their environments in their home directory in a shared machine.

However, as previously mentioned the command for creating environments is completely ignoring the prefix line.

I managed to setup an environment to a specific path using a prefix like this:

conda env create --prefix=<prefix> --file=environment.yaml

but I am trying to figure a way to define the prefix so the user will not have to type it themselves but it will be automatically configured to be their home directory.

like image 391
MattSt Avatar asked Sep 14 '25 02:09

MattSt


1 Answers

I work around the lacking of proper solution by using Makefile target

# project_root/Makefile
# from my experience mamba installs and updates faster than conda
# conda install mamba -n base -c conda-forge
env-create:
    mamba env create -p ./envs -f environment.yml

env-update:
    mamba env update -p ./envs -f environment.yml

usage:

$ make env-create
# or
$ make env-update
like image 97
Nikolay Hidalgo Diaz Avatar answered Sep 15 '25 14:09

Nikolay Hidalgo Diaz