我在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)保存并关闭