Say I have a coworker who doesn't use conda, but instead uses a global python environment.

Is there a way for the coworker to use conda to create a conda environment from his global python environment?

The goal is for me to easily create a conda environment on my computer which matches his python environment.

2 Answers

2
Lokinou On

You could ask your coworker to send his list of currently installed python packages using:

pip freeze > requirements.txt

Without forgetting a pip -V that returns his current version of python.

When the conda environment is set up on your machine with the correct version of python, install the list of packages your coworker gave you:

pip install -r requirements.txt

It will only do the python part, so if additionnal libraries are needed, you might have to install them by hand (for example: c++ redistributables, Qt, imagemagick...)

4
Melvin On

On his side:

pip freeze > requirements.txt

On your side:

conda env create -n [ENV_NAME] -f requirements.txt


EDIT: This only works when 1) both environments are the latest python version, and 2) every package in the specific version that your coworker has, exists in conda. 1 can be resolved through:

conda create -n [ENV_NAME] python=[PYTHON_VER] -f requirements.txt

There isn't a one-step way to do 2 in conda afaik, what I would do is to (as stated in Lokinou's answer) first create a conda env in the desired python version, then install via pip:

conda create -n [ENV_NAME] python=[PYTHON_VER]
conda activate [ENV_NAME]
pip install -r requirements.txt