pip需求文件中的可选依赖关系 [英] Optional dependencies in a pip requirements file

查看:219
本文介绍了pip需求文件中的可选依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在pip需求文件中指定可选依赖项?根据 pip文档,这是可能的,但文档不解释如何做我不能在网络上找到任何示例。

How can I specify optional dependencies in a pip requirements file? According to the pip documentation this is possible, but the documentation doesn't explain how to do it and I can't find any examples on the web.

推荐答案

而不是在与硬要求相同的文件中指定可选依赖项,您可以创建一个 optional-requirements.txt requirements.txt

Instead of specifying optional dependencies in the same file as the hard requirements, you can create a optional-requirements.txt and a requirements.txt.

要将当前环境的包导出到文本文件中,您可以执行以下操作:

To export your current environment's packages into a text file, you can do this:

pip freeze > requirements.txt

如有必要,修改require.txt的内容以准确表示项目的依赖关系。然后,要安装此文件中的所有软件包,请运行:

If necessary, modify the contents of the requirements.txt to accurately represent your project's dependencies. Then, to install all the packages in this file, run:

pip install -U -r requirements.txt

-U 告诉 code>将软件包升级到最新版本,而 -r 告诉它要在require.txt中安装所有软件包。

-U tells pip to upgrade packages to the latest version, and -r tells it to install all packages in requirements.txt.

这篇关于pip需求文件中的可选依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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