Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine the "conda create" parameters "--file", "--prefix" and "--copy"?

Tags:

conda

anaconda

I would like to create a conda environment based on an environment file in a certain path, using no symlinks. Therefore, I would like to run the following conda command:

conda create --file environment.yml --prefix ./python --copy

the file environment.yml looks like this (I shortened it):

name: null
channels:
- defaults
dependencies:
- python==3.7.0

However, I get the following error:

CondaValueError: could not parse 'name: null' in: environment.yml

The following command works:

conda env create --file environment.yml --prefix ./python

However, then I cannot use the --copy parameter:

error: unrecognized arguments: --copy
like image 938
Nos Avatar asked Sep 01 '25 16:09

Nos


1 Answers

While I agree that there really should be an option for this, you can temporarily set the copy_always configuration option to true while you run the command and that should do the trick:

CONDA_COPY_ALWAYS=1 conda env create --file environment.yml --prefix ./python

To verify, I created two versions of the same env with and without CONDA_COPY_ALWAYS=1. They both come out as 969 MB in du alone, but only the one without the CONDA_COPY_ALWAYS=1 gets reduced when including miniconda3/pkgs in the du.

like image 53
merv Avatar answered Sep 07 '25 11:09

merv