pip安装环境。
我有一个emoverial.yml
文件,但不想使用conda:
name: foo
channels:
- defaults
dependencies:
- matplotlib=2.2.2
是否可以在pip
内安装依赖项emoveration.yml 文件好像是
unignts.txt
文件?
我尝试了pip install -r emoverition.yml
,它与pip == 22.1.2
不起作用。
I have an environment.yml
file, but don't want to use Conda:
name: foo
channels:
- defaults
dependencies:
- matplotlib=2.2.2
Is it possible to have pip
install the dependencies inside an environment.yml
file as if it's a requirements.txt
file?
I tried pip install -r environment.yml
and it doesn't work with pip==22.1.2
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
基于 beni 实现,我只是想调整代码,因为它有很多错误;
Based on Beni implementation, I just wanted to adjust the code since it has lots of errors;
我已经实现了什么 brian 在他的评论中建议。
这将
emoverition.yaml
转换为insirase.txt
:这是用
pip
:注意:我省略了错误处理和包装定义的任何其他变化(例如,包装版本的规范大于或等于某个版本),以使其简单。
I've implemented what Brian suggests in his comment.
This converts the
environment.yaml
torequirements.txt
:And this installs the dependencies directly with
pip
:NOTE: I've omitted error handling and any other variations of package definitions (e.g., specification of a package version greater than or equal to a certain version) to keep it simple.
不,
pip
不支持此格式。要求文件的格式记录了在这里。您必须将Environment.yml
文件转换为sumplliance.txt
手动或通过自动化此过程的脚本。但是,请记住,PYPI上并非所有conda上的包装都可以使用。No,
pip
does not support this format. The format it expects for a requirements file is documented here. You'll have to convert theenvironment.yml
file to arequirements.txt
format either manually or via a script that automates this process. However, keep in mind that not all packages on Conda will be available on PyPI.第一个答案提出重要的观点:没有直接的转换,因为conda是一般软件包管理器,因此包括其他包装。此外,Conda软件包通常可以用不同的名称使用。拟议的解析解决方案均未涵盖这种情况。
我个人认为,最有效的完整方法是使用Mamba重新创建环境,然后在环境中使用
pip
抛弃合法的要求.txt 。
也就是说,不要过度思考并使用可靠的工具。
The first answer makes important points: there is not direct conversion because Conda is a general package manager and so includes additional packages. Furthermore, Conda packages can often go by different names. None of the proposed parsing solutions cover this situation.
Personally, I think the most efficacious complete approach is to recreate the environment with Mamba, then use
pip
in the environment to dump out a legitimaterequirements.txt
.That is, don't overthink it and use the reliable tools at hand.
如果您不想使用脚本,我使用以下单元字节来生成需求。从env.yml文件中txt文件:
这只是将所有依赖项都取决于
pip
YML的依赖性并删除了固定版本以单独处理PIP。If you don't want to use a script I've used the following one-liner to generate the requirements.txt file from an env.yml file:
This just takes all of the dependencies under the
pip
dependency in the yml and removes the pinned version for pip to handle on its own.