explosion / spacy-stanza

💥 Use the latest Stanza (StanfordNLP) research models directly in spaCy
MIT License
723 stars 59 forks source link

ImportError: cannot import name 'StanzaLanguage' from partially initialized module 'spacy_stanza' #40

Closed lexmosolov closed 4 years ago

lexmosolov commented 4 years ago

Traceback (most recent call last): File "spacer.py", line 2, in from spacy_stanza import StanzaLanguage File "/Users/lex/.pyenv/versions/3.8.3/lib/python3.8/site-packages/spacy_stanza/init.py", line 2, in from .language import StanzaLanguage File "/Users/lex/.pyenv/versions/3.8.3/lib/python3.8/site-packages/spacy_stanza/language.py", line 2, in from spacy.symbols import POS, TAG, DEP, LEMMA, HEAD File "/Users/lex/Desktop/spacy.py", line 2, in from spacy_stanza import StanzaLanguage ImportError: cannot import name 'StanzaLanguage' from partially initialized module 'spacy_stanza' (most likely due to a circular import) (/Users/lex/.pyenv/versions/3.8.3/lib/python3.8/site-packages/spacy_stanza/init.py)

ines commented 4 years ago

File "/Users/lex/Desktop/spacy.py", line 2, in

I think the problem here is that you've called your file spacy.py, so it's shadowing the installed spacy. You can read more about this concept here: http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html#the-name-shadowing-trap

If you name your file something else, it should work as expected.