我正在尝试在Windows 10上安装Keras。我按照这个特定的顺序安装了Visual Studio 2015 Community Edition,CUDA 8.0,它的第二个补丁,cuDNN 6.0,PyCharm,Anaconda,Python 3.6.3。
我安装了tensorflow-gpu
。
我将\path-to\Python\Python36\bin
添加到PATH
环境变量和NVIDIA文件夹中。 Tensorflow可以从shell运行,但不能从Anaconda提示符运行。
当我尝试使用PowerShell中的pip install keras
安装Keras时出现以下错误。
PS C:\Users\myusr> pip install keras
Collecting keras
Downloading Keras-2.1.1-py2.py3-none-any.whl (302kB)
100% |████████████████████████████████| 307kB 553kB/s
Collecting pyyaml (from keras)
Downloading PyYAML-3.12.tar.gz (253kB)
100% |████████████████████████████████| 256kB 553kB/s
Collecting scipy>=0.14 (from keras)
Downloading scipy-1.0.0-cp36-none-win_amd64.whl (30.8MB)
100% |████████████████████████████████| 30.8MB 41kB/s
Requirement already satisfied: six>=1.9.0 in c:\users\myusr\appdata\local\programs\python\python36\lib\site-packages (from keras)
Requirement already satisfied: numpy>=1.9.1 in c:\users\myusr\appdata\local\programs\python\python36\lib\site-packages (from keras)
Building wheels for collected packages: pyyaml
Running setup.py bdist_wheel for pyyaml ... error
Failed building wheel for pyyaml
Running setup.py clean for pyyaml
Failed to build pyyaml
Installing collected packages: pyyaml, scipy, keras
Running setup.py install for pyyaml ... error
Exception:
Traceback (most recent call last):
File "c:\users\myusr\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8a in position 76: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\myusr\appdata\local\programs\python\python36\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\users\myusr\appdata\local\programs\python\python36\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "c:\users\myusr\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "c:\users\myusr\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_install.py", line 878, in install
spinner=spinner,
File "c:\users\myusr\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
line = console_to_str(proc.stdout.readline())
File "c:\users\myusr\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8a in position 76: invalid start byte
我该怎么办?
答案 0 :(得分:2)
这来自pyyaml模块。基于从版本3.6开始,Python for Windows使用UTF-8作为它的控制台IO会导致错误。在运行子进程的情况下,它认为子进程的输出也是UTF-8 ......实际情况并非如此。
有三种方法可以解决这个问题:
从cmd / powershell:chcp运行命令。它将显示系统默认代码,例如936.打开Lib / site-package / pip / compat / init .py 并且在第76行附近改变
return s.decode('utf_8')
到
return s.decode('cp936')
答案 1 :(得分:0)
在我的Windows 10计算机上安装Keras时情况完全相同。
1)第一步是成功安装pyyaml ,与 easy_install 配合使用,并且没有显示UnicodeDecodeError
easy_install pyyaml
2)再次尝试安装 Keras
pip install keras
3)您可能会收到有关缓存的Keras安装文件的奇怪错误:
zipfile.BadZipFile: Bad CRC-32 for file 'tensorflow-1.8.0.data/purelib/tensorflow/python/_pywrap_tensorflow_internal.pyd'
只需添加no-cache指令
即可 pip install --no-cache-dir keras