如何使用Conda安装python项目的所有依赖项? [英] How to install all dependencies of a python project using Conda?

查看:180
本文介绍了如何使用Conda安装python项目的所有依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是python的新手,正在使用miniconda安装所需的软件包.但是我需要将当前项目移至另一个环境,并且必须在新的虚拟环境上安装该项目中使用的软件包.当我使用pipenv时,我可以安装所有依赖项

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

在conda中有等效的方法吗?还是我必须一个一个地安装软件包?

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

如果可以的话,请您解释一下conda和pipenv的工作原理吗?我知道conda和pipenv都会创建虚拟环境并在venv中安装软件包.我想知道的是如何管理venv上安装的软件包列表.例如,我想了解 Pipfile Pipfile.lock .和康达一样.谢谢.

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.

推荐答案

在要从中迁移的环境中,运行:

In the environment you want to migrate from, run:

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

这将创建一个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

这篇关于如何使用Conda安装python项目的所有依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆