Reputation: 31
I am trying to install keras using pip command but I get this error
Collecting tensorflow>=2.2.0 (from keras)
Could not find a version that satisfies the requirement tensorflow>=2.2.0 (from keras) (from versions: 0.12.1, 1.0.0, 1.0.1, 1.1.0rc0, 1.1.0rc1, 1.1.0rc2, 1.1.0, 1.2.0rc0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.4.1, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0, 1.7.1, 1.8.0rc0, 1.8.0rc1, 1.8.0, 1.9.0rc0, 1.9.0rc1, 1.9.0rc2, 1.9.0, 1.10.0rc0, 1.10.0rc1, 1.10.0, 1.10.1, 1.11.0rc0, 1.11.0rc1, 1.11.0rc2, 1.11.0, 1.12.0rc0, 1.12.0rc1, 1.12.0rc2, 1.12.0, 1.12.2, 1.12.3, 1.13.0rc0, 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 2.0.0a0, 2.0.0b0, 2.0.0b1)
No matching distribution found for tensorflow>=2.2.0 (from keras)
I am installing it using
sudo pip3 install keras
and I have already installed tensorflow using sudo pip3 install tensorflow
how can I solve it ?
Upvotes: 0
Views: 192
Reputation: 5615
Keras has been a part of tensorflow since 2.0. Check out the official docs.
If you have tensorflow>=2.0
installed already, all you have to do is import keras
-
from tensorflow import keras
That's it!
Edit: You'll have to change your import patterns a bit, for example, to import load_model
from keras.models
- you need to do
from tensorflow.keras.models import load_model
The reason you cannot use
from tensorflow import keras
from keras.models import load_model
is simply because python
's import system relies on real packages.
This is very well explained in this answer
The Python import system just doesn't work that way. When you do from foo import bar, foo has to be a "real", fully-qualified package or module name (or a relative one using dots). That is, it has to be something that you could use in a plain import foo. It can't just be a module object you have lying around.
You can also find this information in the import
docs
Upvotes: 1
Reputation: 97
I have the impression that Tensorflow 2 has Keras integrated in it. Try running a test code that uses Keras and see if it's working.
Upvotes: 0