Eka
Eka

Reputation: 15000

How to uninstall Keras?

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.

Upvotes: 22

Views: 70370

Answers (13)

Loseefr Bappy
Loseefr Bappy

Reputation: 1

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!

Upvotes: 0

JY Wang
JY Wang

Reputation: 11

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

sudo pip install keras

Upvotes: 1

AVISHEK GARAIN
AVISHEK GARAIN

Reputation: 835

Use the following command.

 pip install --ignore-installed keras==<version>

Upvotes: 1

Anshuman Kumar
Anshuman Kumar

Reputation: 577

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

Upvotes: 2

Nicola Landro
Nicola Landro

Reputation: 406

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?

Upvotes: 1

Thett Oo Eain
Thett Oo Eain

Reputation: 11

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

Upvotes: 1

Pawan Lakhotia
Pawan Lakhotia

Reputation: 385

In Anaconda prompt type

conda uninstall keras

Upvotes: 3

Yanfeng Liu
Yanfeng Liu

Reputation: 629

Please also check the Anaconda environment if you are using any

Upvotes: 1

m0z4rt
m0z4rt

Reputation: 1225

uninstall keras:

pip uninstall keras -y                                                                                                                                                                            

reinstall with specific version

pip install -Iv keras==2.1.4 

Upvotes: 7

Md. Rezwanul Haque
Md. Rezwanul Haque

Reputation: 2950

You can simply try from the following command:

pip uninstall keras

Upvotes: 18

icoxfog417
icoxfog417

Reputation: 187

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.

Upvotes: 2

Van
Van

Reputation: 3767

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

Upvotes: 0

Eka
Eka

Reputation: 15000

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

Upvotes: 9

Related Questions