Keras breaks Anaconda Prompt

后端 未结 9 1036
天命终不由人
天命终不由人 2020-12-09 06:25

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

<
相关标签:
9条回答
  • 2020-12-09 06:32

    I had the same problem, took me 2 days to finally get things working and many re-installs. This message comes from the following file. %UserProfile%Anaconda3/etc/conda/activate.d/keras_activate.bat. There is some issue in the code written in this file which closes the Anaconda prompt every time. I dont know how to solve it, perhaps someone else can suggest something, but one way to still do some essential tasks on your prompt window is -> RIGHT CLICK ON THE ABOVE MENTIONED FILE AND SELECT EDIT -> WRITE YOUR ANACONDA PROMPT COMMAND AT THE TOP OF THE FILE. (It will execute and then close.)

    0 讨论(0)
  • 2020-12-09 06:34

    I have the same problem. I didn't find a permanent fix, but before the script finishes running, you can escape it using ctrl+d, and you should be able to do whatever you want after that.

    0 讨论(0)
  • 2020-12-09 06:35

    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%\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
    )
    

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

    0 讨论(0)
  • 2020-12-09 06:38

    The best solution I found was ,

    1.Uninstall Keras first

    2.goto the location C:\Users\username\AppData\Local\Continuum\anaconda3\etc\conda\activate.d

    You can see the keras batch files inside in both activate.d and deactivate.d, which runs every time the anaconda prompt is opened.DELETE them.

    3.Reinstall Keras.

    This worked well for me.

    0 讨论(0)
  • 2020-12-09 06:40

    I tried almost every solution to this problem (erasing "nul" from activate.d seemed to work at first, but then conda commands related to packages still crashed the prompt). So this is what I did. The problems seems to originate in the way that conda installs keras.

    1) Uninstall keras using pip. Use the Scripts folder in the Anaconda installation folder.

    2) Manually delete every remaining folder from Keras. Most of them are located in the Anaconda installation folder. Don't forget to delete the keras_activate.bat and keras_deactive.bat files in the activate.d and deactivate.d folders.

    3) Install keras using pip.

    4) That solves the activate.d problem. However, Anaconda Prompt still crashes because of the other file in the %UserProfile%Anaconda3/etc/conda folder, which is called vs2015_compiler_vars.bat. Delete that file and everything will work just fine (weird error messages that appeared while using Keras will also go away).

    P.S. I went through one extra step to make Anaconda Prompt work perfectly, but I don't know if it is related to installing Keras (that's the reason why I am not including it in the answer). As conda commands were getting stuck in "Solving environment", I enabled strich channel priority with conda config --set channel_priority strict. Now Anaconda is totally functional!

    0 讨论(0)
  • 2020-12-09 06:40

    IN below line in .bat file nul is creating the problem and it is closing the terminal please remove nul and this will be solved. So change this

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

    to this

    python -c "import keras" 1> 2>&1
    
    0 讨论(0)
提交回复
热议问题