Miniforge on Windows 10>
I work on several projects at a time and I expected to be able to create environments in custom folders, but my first environment I found in the installation folder of miniforge. How do I create a env in a folder of my choice? I think it must be some setting, but I don’t see any obvious choices.
Two options:
- For individual cases, use
--prefix / -p
flag inconda create
. e.g.conda create --prefix C:\my\custom\location\env python
. - For a global change, use the
envs_dirs
setting in your.condarc
.
Tried this,
mamba create -p D:\01-LouWork\03-PythonWork\envs -n ShipContainers_env -c conda-forge python
but it failed: A lot of configuration failures. Plus there was a root-prefix setting that was missing. But do I execute the create command in the folder that I want the environment created in, or in the miniforge installation folder?
Solved: 1) I used mamba instead of conda. 2) the create command can’t specify both the new env name and its prefix. The name must be part of the prefix, as in -p D:\path to your project folder\X_env.
Just a follow-on… Why can’t I use the same environment and simply store files in different folders for different projects. I know there will be some unused packages for some projects, but how is that a problem?
I assume its best to clone the base environment into a project folder and then install packages into the project env.
Solved… Yes, get into the installation folder. Prepare a bat file with the conda create command and the execute that. The new environment is created in the /path/projfoldr folder… It really works!
It sounds like you’ve worked it out – but for the record, you may want to look at pixi:
It’s designed around what i looks like you want your workflow to be.
However:
I’m not entirely sure what you mean here, but I think this is actually the expected workflow for conda – and why it puts environments in a central location by default.
In some cases (the ones pixi is targetting) there is a 1:1 relationship between projects and environments, in which case keeping the environment entirely within the a “project” dir makes sense.
However, in other cases, like a lot of data analysis work (which conda was originally designed to support) you might have one environment that you use for various projects – and then it makes sense to have a central “data analysis” environment, and use that for work on multiple datasets, etc. In that case, I’m generally not storing my code with the data, or the environment with the code.