我使用此命令安装了Keras:
sudo pip install keras
它正确安装并正常工作,直到我尝试导入应用程序模块:
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
我遇到this link which recommends卸载Keras并直接从GitHub安装Keras:
sudo pip install git+https://github.com/fchollet/keras.git
在从GitHub重新安装Keras之前,我试图使用此命令取消对Keras的解除,但它会抛出此错误:
sudo pip uninstall keras
Can't uninstall 'Keras'. No files were found to uninstall.
您只需尝试以下命令:
pip uninstall keras
我跟着this method来解决我的问题
>> 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
硬卸载:
pip uninstall keras -y
重新安装特定版本
pip install -Iv keras==2.1.4
我想你真的想做的不是卸载keras,而是使用keras.applications.vgg16
。
以下清单将帮助您澄清问题。
我建议首先检查最新的keras,TensorFlow后端(CPU模式),Python3设置。它将解决各种问题。
你可以用
sudo pip -U install keras
做到这一点
如果您使用任何环境,请查看Anaconda环境
在Anaconda提示类型
conda uninstall keras
您可以使用此命令从conda卸载。 conda uninstall keras
试试这个:
sudo pip uninstall git+https://github.com/fchollet/keras.git
如果这不起作用,你可以在sudo pip list
之后看到什么?