Reputation: 15000
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
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
Reputation: 11
I think you can ignore the uninstall process Just install new version keras version is fine
sudo pip install keras
Upvotes: 1
Reputation: 835
Use the following command.
pip install --ignore-installed keras==<version>
Upvotes: 1
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
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
Reputation: 11
you can uninstall from conda by using this command.
conda uninstall keras
Upvotes: 1
Reputation: 629
Please also check the Anaconda environment if you are using any
Upvotes: 1
Reputation: 1225
uninstall keras:
pip uninstall keras -y
reinstall with specific version
pip install -Iv keras==2.1.4
Upvotes: 7
Reputation: 2950
You can simply try from the following command:
pip uninstall keras
Upvotes: 18
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.
I recommend to check latest keras, TensorFlow backend(CPU mode), Python3 setting at first. It will solve various problems.
Upvotes: 2
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