Search code examples
pythonpipcondaimporterrorspacy

Spacy language model installation in python returns ImportError from _mklinit (ImportError: DLL load failed: The specified module could not be found.)


I am currently trying to set up spaCy in my system. When I downloaded the module, no errors are being shown. However, upon downloading a language model (specifically, the english one), I got an error. The output is as follows:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "C:\ProgramData\Anaconda3\lib\site-packages\spacy\__init__.py", line 10, in <module>
    from thinc.neural.util import prefer_gpu, require_gpu
  File "C:\ProgramData\Anaconda3\lib\site-packages\thinc\__init__.py", line 5, in <module>
    import numpy  # noqa: F401
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.

I have tried reinstalling my spaCy package, but still end up getting the same error. How do I deal with this?

I am using Python 3.7.1. Tried downloading using pip install -U spacy and conda install -c conda-forge spacy. I have also tried validating with python -m spacy validate, and it also returns the same error from above.

Thanks.


Solution

  • Thanks to Ines Montani for pointing this out!

    It did seem that a quick reinstallation of numpy helps solve the problem. However, what I did realize is that:

    Using pip uninstall numpy and simple pip install numpy solves the problem.

    However:

    Using conda remove --force numpy and conda install numpy does not solve the problem for me.