【问题标题】:import pystan._api failed:ImportError: DLL load failed: The specified module could not be foundimport pystan._api failed:ImportError: DLL load failed: 找不到指定的模块
【发布时间】:2022-03-24 22:28:50
【问题描述】:

我已经安装了 python 3.7 并想使用 fbprophet (https://facebook.github.io/prophet/docs/installation.html#python) 进行一些预测

但是在使用命令 (pip install fbprophet) 安装包时出现此错误

import pystan
  File "e:\repos\usf\venv\lib\site-packages\pystan\__init__.py", line 9, in <module>
    from pystan.api import stanc, stan
  File "e:\repos\usf\venv\lib\site-packages\pystan\api.py", line 13, in <module>
    import pystan._api  # stanc wrapper
ImportError: DLL load failed: The specified module could not be found.

我进行了一些研究,并了解到 conda 可以做到这一点。但我正在寻找不使用 conda 的解决方案。

提前致谢。

【问题讨论】:

    标签: python importerror pystan


    【解决方案1】:

    它在Pystan documentation 中说,在 Windows 上配置 C++ 编译器可能具有挑战性。以下方法适用于我安装 Pystan 2.17.1 和 FBProphet 0.6:

    1. 安装 C++ 编译器,mingw-w64 (http://mingw-w64.org/doku.php/download) -> 我选择了这个https://sourceforge.net/projects/mingw-w64/files/

    2. 将C:\bin添加到PATH环境变量中

    3. 在 Python 安装目录(在 venv 中)的 \Lib\distutils 文件夹中创建一个 distutils.cfg 文件,内容如下:

      [构建] 编译器=mingw32

      [build_ext] 编译器=mingw32

    4. pip 安装 numpy cython

    5. pip install pystan==2.17.1

    6. 验证 Pystan 安装 (https://pystan.readthedocs.io/en/latest/windows.html)

    7. pip install fbprophet==0.6

    【讨论】:

    • 您使用的是哪个版本的 Python?在 Python 3.8.10 上,我可以成功编译 pystan 2.17.1,但是当我尝试验证它时,导入模块失败:ImportError: DLL load failed while importing _api
    • 对不起,已经有一段时间了,我无法确定发布此答案时使用的 python 版本。很可能是 3.7.7。
    【解决方案2】:

    关注https://github.com/facebook/prophet/issues/1939 即使在安装 Mingw 后我也遇到了类似的问题

    conda install libpython m2w64-toolchain -c msys2 解决了所有错误,我终于可以安装 fbprophet 谢谢

    【讨论】:

      【解决方案3】:

      我的 Python3.6 (anaconda) 也有类似的问题

      我为所有用户(具有管理员权限)重新安装了 anaconda,然后 “conda install -c conda-forge pystan” 后来我更新了所有其他模块

      现在可以正常使用了

      【讨论】:

        猜你喜欢
        • 2017-11-05
        • 2012-08-08
        • 1970-01-01
        • 2023-04-01
        • 2018-11-09
        • 1970-01-01
        • 1970-01-01
        • 2020-06-30
        • 2020-12-04
        相关资源
        最近更新 更多