简体   繁体   中英

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. I do have one, however, Spacy language models require an additional download via (for example) 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 . I know that pip packages can be installed via Conda, but do not know how to perform the "download" inside the environment.yml file. Thanks in advance for any help you can provide.

As the Spacy documentation of download command states:

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. 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. 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 . In the example from OP, this would mean adding the package spacy-model-en_core_web_sm .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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