【问题标题】:ImportError: DLL load failed while importing strings: The specified module could not be foundImportError:导入字符串时DLL加载失败:找不到指定的模块
【发布时间】:2021-09-16 12:48:02
【问题描述】:

我正在尝试在 spaCy 中加载语言模型,但是当我尝试在旧命令和新命令中安装模型时出现错误。

通过旧的短名称安装:

python -m spacy download en
Traceback (most recent call last):
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 188, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 147, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\__init__.py", line 13, in <module>
    from . import pipeline  # noqa: F401
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\pipeline\__init__.py", line 1, in <module>
    from .attributeruler import AttributeRuler
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\pipeline\attributeruler.py", line 6, in <module>
    from .pipe import Pipe
  File "spacy\pipeline\pipe.pyx", line 1, in init spacy.pipeline.pipe
ImportError: DLL load failed while importing strings: The specified module could not be found.

使用较新的全名安装:

python -m spacy download en_core_web_sm
Traceback (most recent call last):
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 188, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 147, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\__init__.py", line 13, in <module>
    from . import pipeline  # noqa: F401
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\pipeline\__init__.py", line 1, in <module>
    from .attributeruler import AttributeRuler
  File "C:\Users\mikkelson\AppData\Local\Programs\Python\Python39\lib\site-packages\spacy\pipeline\attributeruler.py", line 6, in <module>
    from .pipe import Pipe
  File "spacy\pipeline\pipe.pyx", line 1, in init spacy.pipeline.pipe
ImportError: DLL load failed while importing strings: The specified module could not be found.

Python 3.9 是通过 anaconda 安装的,spaCy v 3.0.6 是通过 pip 安装的,我在 Windows 环境中。我该如何解决这个问题?

【问题讨论】:

    标签: python windows anaconda spacy importerror


    【解决方案1】:

    该问题与您尝试下载模型的特定方式无关,而是与加载 DLL (pipe.pyx) 的问题有关,该问题很可能依赖于您缺少的 VS Build Tools (see details here) .

    安装此依赖项后,它应该会开始工作。

    【讨论】:

    • 我没有使用 Visual Studio,我使用的是 pycharm。有什么建议吗?我看到了有关如何从 winpython 获取 DLL 的详细信息,但我不知道如何判断我需要哪个 DLL。谢谢!
    • 这与 IDE 无关,而是需要在 Windows 上安装的运行时库(因为它们是本地编译的 SpaCy 库的依赖项)。
    【解决方案2】:

    遇到同样的问题,被告知问题来自 python3.9,所以我用 3.8 进行了测试,但这并没有帮助,但是安装以下 Visual C++ Redistributable 解决了我的问题https://www.microsoft.com/en-in/download/details.aspx?id=48145

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 2020-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-22
      • 2020-07-01
      • 2021-03-04
      • 2020-07-11
      • 1970-01-01
      相关资源
      最近更新 更多