Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spacy.cli.download doesn't work for transformer model #13072

Closed
Vasniktel opened this issue Oct 19, 2023 · 1 comment
Closed

spacy.cli.download doesn't work for transformer model #13072

Vasniktel opened this issue Oct 19, 2023 · 1 comment
Labels
install Installation issues

Comments

@Vasniktel
Copy link

How to reproduce the behaviour

  1. Create a new virtual env (e.g. in pyenv).
  2. pip install spacy[transformers]==3.7.2.
  3. Start python REPL and:
import spacy
spacy.cli.download('en_core_web_trf')
nlp = spacy.load('en_core_web_trf')
  1. At this point you'll get the following error:

ValueError: [E002] Can't find factory for 'curated_transformer' for language English (en). This usually happens when spaCy calls nlp.create_pipe with a custom component name that's not registered on the current language class. If you're using a Transformer, make sure to install 'spacy-transformers'. If you're using a custom component, make sure you've added the decorator @Language.component (for function components) or @Language.factory (for class components).

Apparently, spacy.cli.download installed curated-transformers as a dependency of en-core-web-trf but couldn't load it. Everything works fine if you reenter the REPL and try spacy.load again.

Your Environment

  • spaCy version: 3.7.2
  • Platform: macOS-14.0-arm64-arm-64bit
  • Python version: 3.9.16
  • Pipelines: en_core_web_trf (3.7.2)
@shadeMe shadeMe added the install Installation issues label Oct 23, 2023
@shadeMe
Copy link
Contributor

shadeMe commented Oct 23, 2023

Thanks for the report! Some context as to why this happens: The spacy[transformers] extra package only installs spacy-transformers whereas the models in 3.7.x depend on spacy-curated-transformers. So, the entry points in the latter are not initialized during the first import spacy call. The spacy.cli.download invocation installs the dependency, but it's too late to reload the entry points, which is why one needs to reload the interpreter/REPL.

We'll look into updating the error message to make it clarify this error case.

@explosion explosion locked and limited conversation to collaborators Oct 23, 2023
@shadeMe shadeMe converted this issue into discussion #13079 Oct 23, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
install Installation issues
Projects
None yet
Development

No branches or pull requests

2 participants