I used miniconda2 but I had to upgrade to miniconda3. However, how can export miniconda2's environments to miniconda3?
Thank you in advance,
UPDATE
I found here the below script:
for env in $(conda env list | cut -d" " -f1); do
if [[ ${env:0:1} == "#" ]] ; then continue; fi;
conda env export -n $env > ${env}.yml
done
It only picks up the new miniconda3 environments and not the old miniconda2 which are located in a different folder.
> ls -1 /work/miniconda2/envs/
3d-dna
abyss
afterqc
busco4
...
(base)> conda activate /work//miniconda2/envs/busco4
(busco4)>
How can I modify the above script to export from miniconda2 folder?
CodePudding user response:
I'm having a hard time finding a conda YML file that's that old. There's no foolproof way that I'm aware of but here is a way that should satisfice the solution.
Note: This is for linux or mac; you can use findstr
for Windows. Or PowerShell.
From your environment:
conda env export --from-history | grep -v "prefix" > your_environment_name.yml
You can view the contents with cat environment.yml
. This gives you the libraries -- but not the dependencies -- and no version numbers for anything. I did that because sometimes a dependent library will get dropped for some reason or another. You may need to modify this with the new version of python you want.
I think this works better than conda env export | cut -f 1 -d '=' | grep -v ^prefix
because, again, sometimes a dependency will get dropped.
From there
conda env create -f your_environment_name.yml -p /home/user/anaconda3/envs/your_environment_name
CodePudding user response:
As alternative approach here is to add the previous Miniconda2 package cache (/work/miniconda2/pkgs
) and environments directory (/work/miniconda2/envs
) to the pkgs_dirs
and envs_dirs
Conda configuration settings. That way you can simply continuing having them available without having to archive and recreate. There are some details in this answer.
You may need to add back the Miniconda3 locations after this if you would like them to continue to be defaults.
Also, because you installed multiple copies of Conda, you should probably check your ~/.bashrc
(and/or ~/.bash_profile
) file to remove any previous sections from conda init
left by the other version.