Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

python - Keras breaks Anaconda Prompt

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I figured out the answer after combining answers from GAURAV and GYAN ARORA. The solution is this:

1) Go to %UserProfile%Anaconda3/etc/conda/activate.dand 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
)

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) Save and close


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...