cloning a virtual env into another directory using

2019-08-20 04:38发布

问题:

I am working on a shared server and trying to clone a virtual env myenv into my home directory.

Here are some facts:

myenv         /path to my home directory/my profile/.conda/envs/myenv
root        * /opt/conda/4.6.14

I currently do not have permissions to install packages into the install area /opt/conda/4.6.14 and so I am trying to clone the myenv into my home directory using this command:

conda create -n myenv_clone -p /path to my home directory/myprofile --clone=/opt/conda/4.6.14

However, this gives me the error: conda create error : --prefix not allowed with -n

My conda info output :

Current conda install:

           platform : linux-64
      conda version : 4.3.16
   conda is private : False
  conda-env version : 4.3.16
conda-build version : not installed
     python version : 2.7.16.final.0
   requests version : 2.21.0
   root environment : /opt/conda/4.6.14  (read only)
default environment : /opt/conda/4.6.14
   envs directories : /home/bridge/c/sheth7/.conda/envs
                      /opt/conda/4.6.14/envs
      package cache : /home/bridge/c/sheth7/.conda/pkgs
       channel URLs : https://repo.continuum.io/pkgs/free/linux-64
                      https://repo.continuum.io/pkgs/free/noarch
                      https://repo.continuum.io/pkgs/r/linux-64
                      https://repo.continuum.io/pkgs/r/noarch
                      https://repo.continuum.io/pkgs/pro/linux-64
                      https://repo.continuum.io/pkgs/pro/noarch
        config file : /home/bridge/c/sheth7/.condarc
       offline mode : False
         user-agent : conda/4.3.16 requests/2.21.0 CPython/2.7.16 Linux

回答1:

The immediate problem is that you can't use both the --prefix|-p and --name|-n flags together. However, the broader description sounds like this isn't the real issue that needs solving. In fact, I don't see why you need to clone myenv - it's already under your home directory.

Since you don't include your full configuration info (e.g., conda info), I can't tell exactly the situation, but on the surface it sounds like the issue isn't with writing to an envs directory but instead about the pkgs directory.

Have a look at the conda config --describe envs_dirs pkgs_dirs documentation. Seeing as you already have myenv where it is, I'd guess you want to do something like:

conda config --append envs_dirs "/path to my home directory/my profile/.conda/envs"
mkdir -p "/path to my home directory/my profile/.conda/pkgs"
conda config --append pkgs_dirs "/path to my home directory/my profile/.conda/pkgs"

Then you should simply be able to use Conda normally. That is, it will automatically fall back to writing to these directories if you don't have privileges in the higher priority locations. So, you shouldn't even need to clone myenv to install packages into it