How to uninstall Keras?
Asked Answered
N

13

22

I have installed Keras using this command:

sudo pip install keras

It installed properly and worked fine until I tried to import application modules:

from keras.applications.vgg16 import VGG16
Using Theano backend.
Couldn't import dot_parser, loading of dot files will not be possible.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named applications.vgg16

I came across this link which recommends to uninstall Keras and directly install Keras from GitHub:

sudo pip install git+https://github.com/fchollet/keras.git

Before reinstalling Keras from GitHub, I tried to unistall Keras using this command but it throws this error:

sudo pip uninstall keras
Can't uninstall 'Keras'. No files were found to uninstall.
Nightly answered 1/1, 2017 at 9:23 Comment(4)
Possible duplicate of python setup.py uninstallNitrogenous
this might help: #35905764Dannettedanni
it is not recommended to use sudo with pip , pip install --user packagename is better.Babita
you should run using like python3 test.pyHide
L
18

You can simply try from the following command:

pip uninstall keras
Louls answered 27/9, 2017 at 5:36 Comment(0)
N
9

I followed this method to solve my problem

>> import keras
>> keras.__path__
['/usr/local/lib/python2.7/dist-packages/keras']

#copy the path
>> sudo  rm -r /usr/local/lib/python2.7/dist-packages/keras

#re installation
>> sudo pip install git+https://github.com/fchollet/keras.git
Nightly answered 3/1, 2017 at 2:15 Comment(1)
This didn't work for me, It gave keras is already installed error when executingpip install command. So, I run sudo pip uninstall keras to remove keras from pip cache, then install it again succesfully.Aecium
C
7

uninstall keras:

pip uninstall keras -y                                                                                                                                                                            

reinstall with specific version

pip install -Iv keras==2.1.4 
Chastise answered 27/3, 2018 at 10:27 Comment(0)
R
3

In Anaconda prompt type

conda uninstall keras
Roobbie answered 24/2, 2019 at 11:26 Comment(0)
C
2

I think you really want to do is not to uninstall the keras, but use the keras.applications.vgg16.
The following checklist will help you to clarify the issue.

  • Keras version: confirm the version of the keras is latest (now 2.0.5)
  • Backend: Theano/Tensorflow or the other
  • Device: GPU or CPU
  • Python version: 2 or 3 and use Anaconda or not
  • Operating system: Mac, Windows, Linux, and so on

I recommend to check latest keras, TensorFlow backend(CPU mode), Python3 setting at first. It will solve various problems.

Congregationalism answered 14/6, 2017 at 5:31 Comment(0)
Y
2

NOTE: Since this edit was rejected for Eka's answer,which worked for me, I added this as answer for folks who have to use Windows.

import keras
print(keras.__path__)
C:\\Users\\oyo\\Anaconda3\\envs\\py36\\lib\\site-packages\\keras

Now in Command Prompt

cd C:\Users\oyo\Anaconda3\envs\py36\lib\site-packages\

rmdir keras
Yclept answered 6/2, 2020 at 12:45 Comment(0)
A
1

Please also check the Anaconda environment if you are using any

Abyssinia answered 26/11, 2018 at 17:43 Comment(0)
K
1

you can uninstall from conda by using this command. conda uninstall keras

Kurus answered 21/3, 2019 at 1:36 Comment(0)
K
1

Try this:

sudo pip uninstall git+https://github.com/fchollet/keras.git

If that does not work, what you can see after sudo pip list?

Kosciusko answered 14/4, 2019 at 14:52 Comment(2)
@Greenonline you can see the exact name of keras module installed, I think that the name should be include keras but not is only keras, removing it keras should be removed.Kosciusko
Eh? Why are you addressing the comment to me? I think there has been some mistake. I merely edited your answer for formatting reasons. If you wish to up[date your answer with more info please use the edit button and not the comments...Stridulous
A
1

Use the following command.

 pip install --ignore-installed keras==<version>
Arteaga answered 22/9, 2020 at 8:43 Comment(0)
T
1

I think you can ignore the uninstall process Just install new version keras version is fine

sudo pip install keras

Thuthucydides answered 29/9, 2020 at 9:29 Comment(0)
T
0

You can simply do that with sudo pip -U install keras

Twinkling answered 12/6, 2017 at 3:29 Comment(2)
That is for installing or upgrading keras. The question asked for uninstallation.Pushy
The ultimate goal is for reinstall Keras tho.Twinkling
I
0

in my case tensorflow 2.13 was working fine with keras 2.14.0, but for randomly downgrading for some requirement, it showed "cast" error, I have tried all method to reinstall keras 2.14 but error was still there. then I have deleted /anaconda3/envs/tf1/lib/python3.10/site-packages/keras folder (for base env, it looks like "/usr/local/lib/python3.10/dist-packages/keras") and reinstalled with

pip install keras==2.14.0

and restarted the kernel then it worked. Basically it was a conflict for randomly upgrading and downgrading thank you!

Incondite answered 5/4 at 2:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.