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.

ImportError: cannot import name 'merge_noun_chunks'

See original GitHub issue

I installed Spacy using the following:

pip install -U spacy
python -m spacy download en

But when I try to load the English language using the following code:

import spacy
nlp = spacy.load('en_core_web_sm', disable=['parser'])

or nlp = spacy.load('en', disable=['parser'])

I got the following error:

Traceback (most recent call last):
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\util.py", line 50, in get_lang_class
    module = importlib.import_module('.lang.%s' % lang, 'spacy')
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\lang\en\__init__.py", line 15, in <module>
    from ...language import Language
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\language.py", line 20, in <module>
    from .pipeline import merge_noun_chunks, merge_entities
ImportError: cannot import name 'merge_noun_chunks'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Ahmadh/PycharmProjects/untitled/NER.py", line 4, in <module>
    nlp = spacy.load('en_core_web_sm', disable=['parser'])
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\__init__.py", line 19, in load
    return util.load_model(name, **overrides)
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\util.py", line 113, in load_model
    return load_model_from_link(name, **overrides)
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\util.py", line 132, in load_model_from_link
    return cls.load(**overrides)
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\data\en_core_web_sm\__init__.py", line 12, in load
    return load_model_from_init_py(__file__, **overrides)
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\util.py", line 177, in load_model_from_init_py
    return load_model_from_path(data_path, meta, **overrides)
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\util.py", line 146, in load_model_from_path
    cls = get_lang_class(meta['lang'])
  File "C:\Users\Ahmadh\AppData\Local\Programs\Python\Python36\lib\site-packages\spacy\util.py", line 53, in get_lang_class
    raise ImportError(msg % lang)
ImportError: Can't import language en from spacy.lang.

Below are the Spacy info I have:

Info about spaCy

* **spaCy version:** 2.0.10
* **Platform:** Windows-10-10.0.16299-SP0
* **Python version:** 3.6.5
* **Models:** en, en_core_web_sm

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
inescommented, Apr 3, 2018

Thanks for the quick update! Did you previously have an older version of spaCy installed? It explicitly fails on merge_noun_chunks, which was introduced in the latest version, so maybe you have some artifacts of the old installation in your environment that weren’t overwritten correctly? (I find that one of the frustrating parts of working with Python and pip is that it’s pretty easy to end up in a weird state – and sometimes, the only thing that helps is starting off with a fresh virtual environment.)

0reactions
lock[bot]commented, May 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix ImportError: Cannot Import Name in Python - Rollbar
The Python ImportError: cannot import name error occurs when an imported class is not accessible or is in a circular dependency.
Read more >
What can I do about "ImportError: Cannot import name X" or ...
I'm assume the error is due to importing entity twice - once in main.py and later in physics.py - but how can I...
Read more >
ImportError: cannot import name '_unicodefun' from 'click' #2976
Describe the bug A recent version of click has been released which removes _unicodefun, breaking black (see also dask/distributed#6013).
Read more >
How do I fix the ImportError: cannot import name 'delayed'?
I am using the LORAS package from pyloras for imbalanced learning, but it requires importing the delayed package. I used the pip.main() to ......
Read more >
How to Fix : “ImportError: Cannot import name X” in Python?
You can solve the “ ImportError : Cannot import name X” Error by resolving the circular dependencies. You can do that either by...
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