简体   繁体   English

Python:在 Windows 上选择 C++ 编译器 — MS Visual Studio 到 Mingw-w64。 (PyStan 编译错误)

[英]Python: Choosing C++ compiler on Windows — MS Visual Studio to Mingw-w64. (PyStan CompileError)

I'm getting a CompileError when running a simple PyStan model in Python:在 Python 中运行简单的 PyStan model 时出现 CompileError:

WARNING:pystan:MSVC compiler is not supported警告:pystan:不支持 MSVC 编译器

Traceback (most recent call last): File "C:\Python36\lib\distutils_msvccompiler.py", line 423, in compile self.spawn(args) File "C:\Python36\lib\distutils_msvccompiler.py", line 542, in spawn return super().spawn(cmd) File "C:\Python36\lib\distutils\ccompiler.py", line 909, in spawn spawn(cmd, dry_run=self.dry_run) File "C:\Python36\lib\distutils\spawn.py", line 38, in spawn _spawn_nt(cmd, search_path, dry_run=dry_run) File "C:\Python36\lib\distutils\spawn.py", line 81, in _spawn_nt "command %r failed with exit status %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 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\panormus\venv2\lib\site-packages\IPython\core\interactiveshell.py", line 3296, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in sm = pystan.StanModel(model_code=mode回溯(最后一次调用):文件“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=mode l) File "C:\panormus\venv2\lib\site-packages\pystan\model.py", line 349, in init build_extension.run() File "C:\Python36\lib\distutils\command\build_ext.py", line 339, in run self.build_extensions() File "C:\Python36\lib\distutils\command\build_ext.py", line 448, in build_extensions self._build_extensions_serial() File "C:\Python36\lib\distutils\command\build_ext.py", line 473, in _build_extensions_serial self.build_extension(ext) File "C:\Python36\lib\distutils\command\build_ext.py", line 533, in build_extension depends=ext.depends) File "C:\Python36\lib\distutils_msvccompiler.py", line 425, in compile raise CompileError(msg) distutils.errors.CompileError: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 1 l) 文件“C:\panormus\venv2\lib\site-packages\pystan\model.py”,第 349 行,在init 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 依赖=ext.depends) 文件中" C:\Python36\lib\distutils_msvccompiler.py",第 425 行,在编译中引发 CompileError(msg) distutils.errors.CompileError: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\ cl.exe' 失败,退出状态为 1

I've isntalled Pystan using pip (pip install PyStan) on Python 3.6 and am trying to run a simple model (first example here )我已经在 Python 3.6 上使用 pip (pip install PyStan) 安装了 Pystan,我正在尝试运行一个简单的model (第一个示例)

I have both MS Visual Studio (not supported) and MinGW-64 (supported) installed on my PC.我的 PC 上同时安装了 MS Visual Studio(不支持)和 MinGW-64(支持)。 MinGW works fine to compile similar models using PyMC3, so it seems to me I just need to get my Pystan package to recognize the installation and use that compiler instead. MinGW 可以很好地使用 PyMC3 编译类似的模型,所以在我看来,我只需要让我的 Pystan package 来识别安装并改用该编译器。 Unfortunately even if that is correct, I am not sure how to do that, can someone help?不幸的是,即使那是正确的,我也不知道该怎么做,有人可以帮忙吗?

Answering myself here.在这里回答自己。 It turns out that others have had similar issues and that the 'standard solution' seems to be to run a conda virtual environment for all pystan modelling.事实证明,其他人也有类似的问题,“标准解决方案”似乎是为所有 pystan 建模运行 conda 虚拟环境。 The pystan docs have detailed installation instructions for conda, which worked for me, but no support for non-conda users. pystan 文档有详细的 conda 安装说明,对我有用,但不支持非 conda 用户。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 适用于Python 2.7的Visual Microsoft Visual C ++编译器与MinGW - Visual Microsoft Visual C++ Compiler for Python 2.7 vs MinGW 使用MinGW C编译器代替Microsoft Visual Studio Express for Python - Using MinGW C compiler instead of Microsoft Visual Studio Express for Python 如何使用 mingw-w64、Python 和 pybind11 手动构建 C++ 扩展? - How can I build manually C++ extension with mingw-w64, Python and pybind11? 如何在 Windows 上使用 MinGW-w64 创建 C 扩展/嵌入 Python - How to create C-extension/embed Python with MinGW-w64 on Windows 绑定 C++ 和 Python 时,SWIG 在具有 MinGW-w64 的 Windows 上不起作用:导入时 DLL 加载失败:找不到指定的模块 - SWIG doesn't work on Windows with MinGW-w64 when binding C++ and Python: DLL load failed while importing: The specified module could not be found ValueError:尝试使用 mingw-w64 进行编译时,未知 MS 编译器版本 1916 - ValueError: Unknown MS Compiler version 1916 when trying to compile with mingw-w64 Pystan -- Library\\mingw-w64\\bin\\gcc.exe' 失败,退出代码为 1 - Pystan -- Library\\mingw-w64\\bin\\gcc.exe' failed with exit code 1 pystan:CompileError:命令'gcc'失败,退出状态为1(Windows) - pystan: CompileError: command 'gcc' failed with exit status 1 (Windows) Python 3,如何设置Visual Studio C ++ 2015编译器? - Python 3, How to set Visual Studio C++ 2015 compiler? 无法配置Python 3.5以在Windows上使用Visual C ++编译器 - Cannot configure Python 3.5 to use Visual C++ compiler on Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM