importpipexportcondaclone

How to clone conda environment, which have pip packages besides of conda packages?


Context

I am trying to clone my dev conda environment to a test server. In this environment besides of many conda packages I had to install some packages via pip. I am using miniconda.

What I've tried:

conda list --explicit > spec-file.txt

then

conda create --name myclonedenv --file spec-file.txt

however this is not installing the few packages what were installed via pip in the original conda environment.

Question

How can I export a current conda environment, and clone it on an other machine, if the current conda environment contains some packages installed via pip


Solution

  • The conda env export command will capture both Conda- and Pip-installed packages. The YAML can then be used with conda env create to recreate the environment.