question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't import en_core_web_trf: AttributeError: module 'spacy.lang.en' has no attribute '__all__'

See original GitHub issue

How to reproduce the behaviour

I am using what loads at this time as spacy-nightly[transformers,cuda100], on Google Colab’s Python3.

The following code was run:

!pip install snorkel spacy-nightly[transformers,cuda100] --pre

import spacy
import spacy_transformers

from spacy.cli import download
download("en_core_web_trf")

nlp = spacy.load("en_core_web_trf")

The following exception occurs:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-19-911d29e313e9> in <module>()
----> 1 nlp = spacy.load("en_core_web_trf")

7 frames
/usr/local/lib/python3.6/dist-packages/spacy/util.py in get_lang_class(lang)

AttributeError: module 'spacy.lang.en' has no attribute '__all__'

Your Environment

  • Operating System: (Colab) Linux 5a8332f5cac4 4.19.112+ #1 SMP Thu Jul 23 08:00:38 PDT 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Python Version Used: Python 3.6.9
  • spaCy Version Used: spacy-nightly==3.0.0rc5
  • Environment Information: Rain.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rjurneycommented, Jan 27, 2021

You were correct. I had installed spacy-nightly without uninstalling the included spacy first. Then I installed spacy-nightly and removed the original spacy, which messed things up.

The solution to install this in Colab is:

!yes | pip uninstall spacy
!pip install spacy-nightly[cuda100,transformers] --pre

After this the following code runs fine:

import spacy
import spacy_transformers
from spacy.cli import download


download("en_core_web_trf")
nlp = spacy.load("en_core_web_trf")

However, download now seems superfluous according to the debug output, since load can download.

@honnibal is there a relevant place in the documentation to add this? I would like to make my first PR if there is 😃

0reactions
rjurneycommented, Jan 30, 2021

@ines could I update the install instructions for Colab?

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: module 'spacy' has no attribute 'load'
In Python distinctive files are modules, and therefore by naming it 'spacy', you overwrite the file and import itself.
Read more >
Install spaCy · spaCy Usage Documentation
Import error: No module named spacy ... This error means that the spaCy module can't be located on your system, or in your...
Read more >
Models & Languages · spaCy Usage Documentation
spaCy is a free open-source library for Natural Language Processing in Python. It features NER, POS tagging, dependency parsing, word vectors and more....
Read more >
English · spaCy Models Documentation
spaCy is a free open-source library for Natural Language Processing in Python. It features NER, POS tagging, dependency parsing, word vectors and more....
Read more >
spaCy 101: Everything you need to know
What's spaCy? spaCy is a free, open-source library for advanced Natural Language Processing (NLP) in Python. If you're working with a lot of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found