微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

python – Keras打破了Anaconda Prompt

我在Anaconda发行版上从tensorflow切换到keras,后者遇到了一些问题.我使用命令通过Anaconda提示安装它

conda install keras

我认为安装没有正确完成,因为它运行命令

python -c "import keras"  1>nul 2>&1

关闭提示.之后,如果我要打开命令行,它会自动运行上面的命令并关闭它,所以我无法使用提示符.这适用于Anaconda 5.3.1(Python 3.7)和Anaconda 5.2.0(Python 3.6).

非常感谢你提前.任何帮助都感激不尽.

解决方法

在结合GAURAV和GYAN ARORA的答案后,我想出了答案.解决方案是这样的:

1)转到%UserProfile%Anaconda3 / etc / conda / activate.d并右键单击keras_activate.bat
2)点击编辑.这就是.bat文件的样子:

:: figure out the default Keras backend by reading the config file.
python %CONDA_PREFIX%\etc\keras\load_config.py > temp.txt
set /p KERAS_BACKEND=<temp.txt
del temp.txt

:: Try to use the default Keras backend.
:: Fallback to Theano if it fails (Theano always works).
python -c "import keras" 1>nul 2>&1
if errorlevel 1 (
    ver > nul
    set "KERAS_BACKEND=theano"
    python -c "import keras" 1>nul 2>&1
)

将1> nul改为1>.最终文件应如下所示:

:: figure out the default Keras backend by reading the config file.
python %CONDA_PREFIX%\etc\keras\load_config.py > temp.txt
set /p KERAS_BACKEND=<temp.txt
del temp.txt

:: Try to use the default Keras backend.
:: Fallback to Theano if it fails (Theano always works).
python -c "import keras" 1> 2>&1
if errorlevel 1 (
    ver > nul
    set "KERAS_BACKEND=theano"
    python -c "import keras" 1> 2>&1
)

3)保存并关闭

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐