I want to MOVE a conda environment, but there is no conda command to do that.
I GUESS this because conda "hard-links" packages to the environment and runtime config variables, and conda index or Anaconda index and hard-links are not updated correctly. I make this assumption based on conda create --clone v.s. copying the environment directly (Someone please clarify if this assumption is wrong.)
So a workaround for this current conda limitation (no "move" command) is to "build an identical environment" from the parent environment. I followed these instructions Building Identical conda environments:
conda create --name myenv --file spec-file.txt
but they don't work because I get a conda error:
conda-script.py create: error: argument -n/--name: not allowed with argument -p/--prefix
:
This is a two-step process:
create a specification file that lists all packages and versions in the parent environment:
conda list --explicit > spec-file.txt
use this package specification list (the file 'spec-file.txt') to recreate the parent environment, but use a NEW name for the child environment, since the conda index needs a unique name. (Again, someone please clarify if this is a wrong assumption.)
But the following command with location and environment name gives an error (target location "C:\ProgramData\Anaconda3\envs" ; new environment name is "newenv2").
conda create --prefix "C:\\ProgramData\\Anaconda3\\envs" --name topss2 --file spec-file.txt
ERROR:
conda-script.py create: error: argument -n/--name: not allowed with argument -p/--prefix
I want to be able to do this in one command and specify the new (named) environment packages from spec-file.txt, and specify the location myself (not taking the Anaconda default, which in my case is C:\\Users\\richadmin\\.conda\\envs\\topss
).
IT WORKS, BUT NOT WITHOUT MANUAL STEPS
I finally got it to work by using conda create --name myclone --clone myenv
. However, I had to manually change to the target directory and then execute the clone command without the spec-file or target directory name. I want to do it in one step to use it on a command line, script or docker build.
QUESTION: Does anyone know if options exist for this:
conda create --name myclone --clone clone_env_name --prefix target_directory
Where is conda --move
in the conda command set?
We need a conda "move environment" command in the core conda package. It is easy to accidentally create new environments in the wrong locations. A conda "move" command should just update config variables and hard-links. This would stop wasting file space and time cloning and deleting incorrectly-located environments. (Yeah, I know, "use the command line correctly in the first place", or understand Anaconda's intricate and hidden configuration interface.) This is a common newbie and intermediate-level Python environment usage error that will benefit from a more complete conda
command set.
Anaconda uses its own default directories and this causes problems for Python users in corporate IT environments, because corporate IT wants to install files in places like: C:\Users\richadmin\AppData\Roaming
or c:\users\username\.conda\envs
, or c:\program files\
.
I typically use c:\programdata\anaconda3\envs
because then this doesn't bump heads with file permission and execution issues in corporate environments.