无法在 Windows 10 上安装 Keras

Cannot install Keras on Windows 10

我在 windows 10 和 python 3.6.3 上安装 Keras 时遇到问题。 当我执行

pip3 install keras

我安装包 PyYAML 失败:

Installing collected packages: pyyaml, keras    
...
checking if libyaml is compilable
error: [WinError 3] The system cannot find the path specified: 'D:\Program Files\Microsoft Visual Studio 14.0\VC\PlatformSDK\lib'

----------------------------------------
Failed building wheel for pyyaml

似乎缺少对 Visual Studio 的依赖?有人遇到过这个吗?

最新的 PyYAML (3.12) 在 Python 3.6.0 可用之前发布。由于过去几年的低维护模式,Python 版本没有可用的轮子。 因此,您从源 (.zip) 文件安装,pip 首先尝试为其缓存制作轮子,因此需要 Visual Studio 编译器 CLoader/CDumper.

我上次(几年前)在 PyYAML 中查看 setup.py,检查是否可以编译,如果不能,则在没有 C 扩展的情况下继续安装。 setup.pypip 中的更改导致无论如何都会尝试此操作,从而导致此错误。生成的轮子将存储在 pip 的缓存中。

除了切换到Python3.5,或者安装Visual Studio(比较麻烦),你可以尝试使用:

pip3 install --no-binary pyyaml --no-cache-dir keras

Anthon的回答对定位问题很有帮助,但并没有直接帮我解决问题。截至今天,在 Windows 上安装 PyYAML 时问题仍然存在。我最终下载了主分支并删除了编译行。

我在 GitHub 上发布了一个问题,你可以在这里找到它:https://github.com/yaml/pyyaml/issues/166。它包含应该被注释掉的代码。