Keras 打破 Anaconda 提示 [英] Keras breaks Anaconda Prompt
问题描述
我正在 Anaconda 发行版上从 tensorflow 切换到 keras,并且在使用后者时遇到了一些问题.我使用命令通过 Anaconda 提示符安装它
I am switching from tensorflow to keras on my Anaconda distribution and am having some problems with the latter. I install it through Anaconda prompt with the command
conda install keras
并且我认为安装没有正确完成,因为它运行命令
and I do not think the installation is properly finished since it runs the command
python -c "import keras" 1>nul 2>&1
并关闭提示.之后,如果我要打开命令行,它会自动运行上面的命令并将其关闭,因此我无法使用提示.Anaconda 5.3.1 (Python 3.7) 和 Anaconda 5.2.0 (Python 3.6) 都发生了这种情况.
and closes the prompt. Afterwards, if I am to open the command line it automatically runs the command above and closes it, so I am unable to use the prompt. This has happened for both Anaconda 5.3.1 (Python 3.7) and Anaconda 5.2.0 (Python 3.6).
在此先非常感谢您.任何帮助将不胜感激.
Thank you very much in advance. Any help will be much appreciated.
推荐答案
我在结合 GAURAV 和 GYAN ARORA 的答案后找到了答案.解决办法是这样的:
I figured out the answer after combining answers from GAURAV and GYAN ARORA. The solution is this:
1) 转到 %UserProfile%Anaconda3/etc/conda/activate.d
并右键单击 keras_activate.bat
2)点击编辑.这是 .bat 文件的样子:
1) Go to %UserProfile%Anaconda3/etc/conda/activate.d
and right click on keras_activate.bat
2) Click on edit. This is what the .bat file looks like:
:: 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>
.最终文件应如下所示:
Change both 1>nul
to 1>
. The final file should look like this:
:: 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) 保存并关闭
这篇关于Keras 打破 Anaconda 提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!