1

I'm a newbie of python and installing needed packages using miniconda. But I need to move current project to another environment and I have to install packages used in the project on the new virtual environment. When I use pipenv, I can install all dependancies like this

$pipenv install

Is there an equivalent way in conda? Or do I have to install packages one by one?

And if you can, would you please explain the principles conda and pipenv work? I know both conda and pipenv create virtual environment and install packages in the venv. What I want to know is how to manage the package list being installed on venv. For example, I want know about the Pipfile and Pipfile.lock. And the same in conda. Thanks.

Ma Long
  • 135
  • 2
  • 11
  • 1
    Pip holds dependencies in `requirements.txt` and those can be installed with `pip install -r requirements.txt`. Pipenv holds dependencies in the `Pipfile` and can be installed with `pipenv install` in the same directory as the `Pipfile`. Conda projects typically hold dependencies in `environment.yml` and they are usually installed into a new environment with `conda env create -f environment.yml` – alkasm Jan 28 '20 at 00:58
  • It's been a bit since I've used venv, but afair Pipfile contains all the dependent packages (and their dependencies and version restrictions) for your project. Pipfile.lock specifies the version of each package you had installed the last time you ran your app successfully. (If you require package xyz version > 13.0, the latest is 15.0, but you had it running on 14.0 it installs 14.0) – bbbbbb Jan 28 '20 at 00:59

1 Answers1

3

In the environment you want to migrate from, run:

conda env export -n <environment name> -f spec.yaml

This will create a YAML file that you can use to recreate the environment. To create a new environment run:

conda env create -n <new env name> -f spec.yaml
James
  • 32,991
  • 4
  • 47
  • 70