简体   繁体   English

直接从 Conda environment.yml 安装 Spacy 语言模型

[英]Installing Spacy language models directly from Conda environment.yml

In hopes of facilitating the installation of a tool I have built, I would like to have an enviroment.yml file that could help install all the required dependencies.为了方便我构建的工具的安装,我想要一个enviroment.yml文件,它可以帮助安装所有必需的依赖项。 I do have one, however, Spacy language models require an additional download via (for example) python -m spacy download en_core_web_sm .我确实有一个,但是,Spacy 语言模型需要通过(例如) python -m spacy download en_core_web_sm进行额外下载。

My issue is that I would like to have this model downloaded from a simple conda env create -f environment.yml .我的问题是我想从一个简单的conda env create -f environment.yml下载这个模型。 I know that pip packages can be installed via Conda, but do not know how to perform the "download" inside the environment.yml file.我知道可以通过 Conda 安装 pip 包,但不知道如何在environment.yml文件中执行“下载”。 Thanks in advance for any help you can provide.提前感谢您提供的任何帮助。

As the Spacy documentation of download command states:正如download命令的 Spacy 文档所述:

DOWNLOADING BEST PRACTICES下载最佳实践
The download command is mostly intended as a convenient, interactive wrapper – it performs compatibility checks and prints detailed messages in case things go wrong. download命令主要用作方便的交互式包装器 - 它执行兼容性检查并打印详细消息以防出现问题。 It's not recommended to use this command as part of an automated process.不建议将此命令用作自动化过程的一部分。 If you know which package your project needs, you should consider a direct download via pip , or uploading the package to a local PyPI installation and fetching it straight from there.如果你知道你的项目需要哪个包,你应该考虑通过 pip 直接下载,或者将包上传到本地 PyPI 安装并直接从那里获取。 This will also allow you to add it as a versioned package dependency to your project.这也将允许您将其作为版本化包依赖项添加到您的项目中。

While it is possible to include PyPI dependencies in a Conda environment YAML, Conda Forge also publishes Spacy models as packages via the spacy-models-feedstock .虽然可以在 Conda 环境 YAML 中包含 PyPI 依赖项,但 Conda Forge 还通过spacy-models-feedstock feedstock 将 Spacy 模型作为包发布。 In the example from OP, this would mean adding the package spacy-model-en_core_web_sm .在 OP 的示例中,这意味着添加包spacy-model-en_core_web_sm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM