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.
petezurich
  • 9,280
  • 9
  • 43
  • 57
Eka
  • 14,170
  • 38
  • 128
  • 212

12 Answers12

18

You can simply try from the following command:

pip uninstall keras
Md. Rezwanul Haque
  • 2,882
  • 7
  • 28
  • 45
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
Community
  • 1
  • 1
Eka
  • 14,170
  • 38
  • 128
  • 212
  • This didn't work for me, It gave `keras is already installed` error when executing`pip install` command. So, I run `sudo pip uninstall keras` to remove keras from pip cache, then install it again succesfully. – mkocabas Nov 19 '17 at 09:03
7

uninstall keras:

pip uninstall keras -y                                                                                                                                                                            

reinstall with specific version

pip install -Iv keras==2.1.4 
m0z4rt
  • 1,055
  • 2
  • 17
  • 25
3

In Anaconda prompt type

conda uninstall keras
Onur A.
  • 3,007
  • 3
  • 22
  • 37
Pawan Lakhotia
  • 385
  • 1
  • 10
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.

icoxfog417
  • 137
  • 1
  • 4
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
Anshuman Kumar
  • 464
  • 1
  • 6
  • 20
1

Please also check the Anaconda environment if you are using any

Yanfeng Liu
  • 549
  • 5
  • 10
1

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

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?

Greenonline
  • 1,330
  • 8
  • 23
  • 31
Nicola Landro
  • 336
  • 3
  • 17
  • @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. – Nicola Landro Apr 15 '19 at 06:38
  • 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... – Greenonline Apr 15 '19 at 08:52
1

Use the following command.

 pip install --ignore-installed keras==<version>
AVISHEK GARAIN
  • 715
  • 5
  • 6
1

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

sudo pip install keras

JY Wang
  • 11
  • 1
0

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

Van
  • 3,749
  • 1
  • 15
  • 15