加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – Keras打破了Anaconda Prompt

发布时间:2020-12-20 11:08:24 所属栏目:Python 来源:网络整理
导读:我在Anaconda发行版上从tensorflow切换到keras,后者遇到了一些问题.我使用命令通过Anaconda提示安装它 conda install keras 我认为安装没有正确完成,因为它运行命令 python -c "import keras" 1nul 21 并关闭提示.之后,如果我要打开命令行,它会自动运行上面
我在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%etckerasload_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%etckerasload_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)保存并关闭

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读