'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 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 merv