【问题标题】:Python: Choosing C++ compiler on Windows -- MS Visual Studio to Mingw-w64. (PyStan CompileError)Python:在 Windows 上选择 C++ 编译器——从 MS Visual Studio 到 Mingw-w64。 (PyStan 编译错误)
【发布时间】:2019-10-12 14:43:56
【问题描述】:

在 Python 中运行简单的 PyStan 模型时出现 CompileError:

警告:pystan:MSVC 编译器不受支持

Traceback(最近一次调用最后一次):文件 “C:\Python36\lib\distutils_msvccompiler.py”,第 423 行,在编译中 self.spawn(args) 文件“C:\Python36\lib\distutils_msvccompiler.py”,第 542 行,在 spawn 返回 super().spawn(cmd) 文件“C:\Python36\lib\distutils\ccompiler.py”,第 909 行,在 spawn spawn(cmd, dry_run=self.dry_run) 文件“C:\Python36\lib\distutils\spawn.py”,第 38 行,在 spawn _spawn_nt(cmd, search_path, dry_run=dry_run) 文件“C:\Python36\lib\distutils\spawn.py”,第 81 行,在 _spawn_nt “命令 %r 失败,退出状态为 %d”% (cmd, rc)) distutils.errors.DistutilsExecError: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 1 在处理上述异常期间, 发生另一个异常:Traceback(最近一次调用最后一次):文件 "C:\panormus\venv2\lib\site-packages\IPython\core\interactiveshell.py", 第 3296 行,在 run_code 中 exec(code_obj, self.user_global_ns, self.user_ns) 文件“”,第 1 行,在 sm = pystan.StanModel(model_code=model) 文件“C:\panormus\venv2\lib\site-packages\pystan\model.py”,第 349 行,在 初始化 build_extension.run() 文件“C:\Python36\lib\distutils\command\build_ext.py”,第 339 行,运行中 self.build_extensions() 文件“C:\Python36\lib\distutils\command\build_ext.py”,第 448 行,在 build_extensions self._build_extensions_serial() 文件“C:\Python36\lib\distutils\command\build_ext.py”,第 473 行,在 _build_extensions_serial self.build_extension(ext) 文件“C:\Python36\lib\distutils\command\build_ext.py”,第 533 行,在 build_extension depends=ext.depends) 文件“C:\Python36\lib\distutils_msvccompiler.py”,第 425 行,在编译 raise CompileError(msg) distutils.errors.CompileError: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' 失败,退出状态为 1

我已经在 Python 3.6 上使用 pip (pip install PyStan) 安装了 Pystan,并且正在尝试运行一个简单的模型(第一个示例 here

我的 PC 上同时安装了 MS Visual Studio(不支持)和 MinGW-64(支持)。 MinGW 可以很好地使用 PyMC3 编译类似的模型,所以在我看来,我只需要让我的 Pystan 包来识别安装并改用那个编译器。不幸的是,即使那是正确的,我也不知道该怎么做,有人可以帮忙吗?

【问题讨论】:

    标签: python c++ pystan


    【解决方案1】:

    在这里回答自己。事实证明,其他人也有类似的问题,“标准解决方案”似乎是为所有 pystan 建模运行 conda 虚拟环境。 pystan 文档有详细的 conda 安装说明,这对我有用,但不支持非 conda 用户。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-23
      • 1970-01-01
      • 2013-10-03
      • 1970-01-01
      • 2019-06-25
      相关资源
      最近更新 更多