spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

ImportError: DLL load failed: The specified module could not be found.

Open KarlHC opened this issue 6 years ago • 7 comments

How to reproduce the behaviour

When running my python script in a Docker container on Windows, I get the following error when importing spacy :

Traceback (most recent call last):
  File "application.py", line 5, in <module>
    import spacy
  File "C:\Python\lib\site-packages\spacy\__init__.py", line 12, in <module>
    from . import pipeline
  File "C:\Python\lib\site-packages\spacy\pipeline\__init__.py", line 4, in <module>
    from .pipes import Tagger, DependencyParser, EntityRecognizer, EntityLinker
  File "pipes.pyx", line 1, in init spacy.pipeline.pipes
ImportError: DLL load failed: The specified module could not be found.

Exactly the same issue has been described before, see https://github.com/explosion/spaCy/issues/4733, albeit not running in Docker

When I execute the same script on the host computer, it runs fine (same python and spacy versions as in the container)

Environment

  • Operating System: Windows Server 2016
  • Python Version Used: 3.7.5
  • spaCy Version Used: 2.2.4
  • Environment Information:

KarlHC avatar Mar 27 '20 14:03 KarlHC

This usually points to the fact that spaCy was not installed properly (as in the cited thread), or perhaps there are some conflicting packages.

From your output, it looks like you're not working in a virtual environment, which I would definitely recommend. So I would advice to create an entirely new venv, then install spaCy again from scratch.

If it doesn't work, can you share the full install logs?

svlandeg avatar Apr 15 '20 09:04 svlandeg

This issue has been automatically closed because there has been no response to a request for more information from the original author. With only the information that is currently in the issue, there's not enough information to take action. If you're the original author, feel free to reopen the issue if you have or find the answers needed to investigate further.

no-response[bot] avatar Apr 29 '20 09:04 no-response[bot]

Hallo uit Gent! ;-)

Sorry for the late response, but I'm still struggling with installing spacy in a windows docker container.

I tried your suggestion by creating a virtual environment, but the issue remains the same... I realize you may not be a docker expert (and me neither), but this is my Docker file:

FROM python-3-7-5-base

EXPOSE 8000

CMD python -m venv spacy-env

WORKDIR /spacy-env
ADD . /spacy-env

CMD ./Scripts/activate.bat

RUN pip install -r requirements.txt

RUN pip install -U spacy-lookups-data 
RUN pip install -U lemminflect 
RUN pip install -U spacy_iwnlp 
RUN pip install -U spacy_lefff

CMD python application.py

The python-3-7-5-base is just a base image for python in a windows server 2016 container.

The requirements.txt file:

hug>=2.4.0,<2.5.0
hug-middleware-cors>=1.0.0,<2.0.0
spacy>=2.2.2,<2.3.0
waitress>=1.0.2,<2.0.0

https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-2.2.5/en_core_web_lg-2.2.5.tar.gz#egg=en_core_web_lg==2.2.5
https://github.com/explosion/spacy-models/releases/download/de_core_news_md-2.2.5/de_core_news_md-2.2.5.tar.gz#egg=de_core_news_md==2.2.5
https://github.com/explosion/spacy-models/releases/download/fr_core_news_md-2.2.5/fr_core_news_md-2.2.5.tar.gz#egg=fr_core_news_md==2.2.5
https://github.com/explosion/spacy-models/releases/download/nl_core_news_sm-2.2.5/nl_core_news_sm-2.2.5.tar.gz#egg=nl_core_news_sm==2.2.5

The container builds ok, but when I run it I get the error in my original post.

Any help much appreciated!

KarlHC avatar May 07 '20 09:05 KarlHC

After installing it like this, what is the error you're getting?

If it's exactly the same, the code is not running in the virtual environment. In that case, you need to check your settings and check which python etc and ensure it's properly run in your new, clean environment.

If it's different than your original post, could you paste the full stack trace?

svlandeg avatar May 08 '20 11:05 svlandeg

This issue has been automatically closed because there has been no response to a request for more information from the original author. With only the information that is currently in the issue, there's not enough information to take action. If you're the original author, feel free to reopen the issue if you have or find the answers needed to investigate further.

no-response[bot] avatar May 22 '20 12:05 no-response[bot]

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.

lock[bot] avatar Jun 24 '20 22:06 lock[bot]

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.

lock[bot] avatar Jun 24 '20 22:06 lock[bot]