Streamlit: ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow` im getting this error but i have installed tensorflow and everything

Created on 21 Jun 2020  路  24Comments  路  Source: streamlit/streamlit

Summary

Type here a clear and concise description of the bug. Aim for 2-3 sentences.

Steps to reproduce

What are the steps we should take to reproduce the bug:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'

Expected behavior:

Explain what you expect to happen when you go through the steps above, assuming there were no bugs.

Actual behavior:

Explain the buggy behavior you experience when you go through the steps above.
If applicable, add screenshots to help explain your problem.

Is this a regression?

That is, did this use to work the way you expected in the past?
yes / no

Debug info

  • Streamlit version: (get it with $ streamlit version)
  • Python version: (get it with $ python --version)
  • Using Conda? PipEnv? PyEnv? Pex?
  • OS version:
  • Browser version:

Additional information

If needed, add any other context about the problem here. For example, did this bug come from https://discuss.streamlit.io or another site? Link the original source here!

bug onboarding

Most helpful comment

I faced a similar issue and I followed this: https://stackoverflow.com/questions/62465620/error-keras-requires-tensorflow-2-2-or-higher and then still had some compatibility issues which were fixed with:
pip install --ignore-installed --upgrade tensorflow==1.6.0
pip install keras==2.1.5

All 24 comments

I'm also facing the same issue

Hello @prasrahul and @Aathib -

Can you provide more information about your operating system, version of Streamlit, how you installed the packages, and the code that you ran? Without any information here, it's hard to know what the problem might be or how to help.

im using windows 10, i have installed latest version of streamlit, i have installed the packages by pip install in the anaconda prompt,

this is the code i have ran

import streamlit as st
from keras.models import load_model
import numpy as np
from keras.preprocessing import image



st.title('Object detector using VGG16')
st.text('This detector can predict 8 classes: Aeroplane,Car,Cat,Dog,Flower,Fruit,Motorbike and Person')

st.sidebar.header( "options")
select_box=st.sidebar.radio('select one',('application','about'))

if select_box=='about':
    st.write('this is the about page')
elif select_box=='application':
    image= st.file_uploader('upload image',type=['jpg','jpeg','png'])
    st.text('your uploaded image')
    st.image(image)
if st.button('predict'):
    # load model

    model = load_model('VGGmodel.h5')
    test_image = image.load_img(image, target_size=(224, 224))
    test_image = image.img_to_array(test_image)
    test_image = np.expand_dims(test_image, axis=0)
    result = model.predict(test_image)

    if result[0][0] == 1:
        prediction = 'aeroplane'

    elif result[0][1] == 1:
        prediction = 'car'


    elif result[0][2] == 1:
        prediction = 'cat'

    elif result[0][3] == 1:
        prediction = 'dog'

    elif result[0][4] == 1:
        prediction = 'flower'


    elif result[0][5] == 1:
        prediction = 'fruit'


    elif result[0][6] == 1:
        prediction = 'motorbike'



    else:
        result[0][7] == 1
        prediction = 'person'

    st.success(prediction)

I faced a similar issue and I followed this: https://stackoverflow.com/questions/62465620/error-keras-requires-tensorflow-2-2-or-higher and then still had some compatibility issues which were fixed with:
pip install --ignore-installed --upgrade tensorflow==1.6.0
pip install keras==2.1.5

i was getting this issue with last couple of days. i uninstalled first dependent pkg using pip and pip3 first. made venv. then installed in sequence.
uninstall

  1. pip uninstall pandas...(below 6 lib)
    2.pip3 uninstall pandas...(below 6 lib)
    3.in venv install
    pip install pandas
    h5py
    Keras
    numpy
    streamlit
    setuptools
    tensorflow

it worked.

Thanks for letting us know @chandranitu!

I'm going to close this issue, since it seems like it's not a Streamlit issue specifically, but a pip/package install issue. If the issue persists, please feel free to comment and I'll re-open

@randyzwitch, I am also facing the same issue. please help, I am not able to solve the problem.

i have tensorflow version 2.2 downloaded still facing same problem

Per @chandranitu's post, it sounds like this is a combination of weird pip installs and having to do them in a special order. There's nothing specifically Streamlit that's causing these issues as far as I can tell.

Oh well, I have solved my problem by installing https://download.visualstudio.microsoft.com/download/pr/d60aa805-26e9-47df-b4e3-cd6fcc392333/7D7105C52FCD6766BEEE1AE162AA81E278686122C1E44890712326634D0B055E/VC_redist.x64.exe.
Restart your computer after installing it.

Thanks a lot.. This worked!

Oh well, I have solved my problem by installing https://download.visualstudio.microsoft.com/download/pr/d60aa805-26e9-47df-b4e3-cd6fcc392333/7D7105C52FCD6766BEEE1AE162AA81E278686122C1E44890712326634D0B055E/VC_redist.x64.exe.
Restart your computer after installing it.

Thank you so much iqbal...It worked馃槉馃槉

Oh well, I have solved my problem by installing https://download.visualstudio.microsoft.com/download/pr/d60aa805-26e9-47df-b4e3-cd6fcc392333/7D7105C52FCD6766BEEE1AE162AA81E278686122C1E44890712326634D0B055E/VC_redist.x64.exe.
Restart your computer after installing it.

Thank you so much iqbal...It worked馃槉馃槉

still iam getting error.please help mein this

@ArunvardhanReddy which version of tensorflow do you have
if you are having tensorflow version==2.1, try installing keras version==2.3.1 compatible with python version>=3.6

by simply writing a command on anaconda\command prompt as "conda install keras==2.3.1"

Oh well, I have solved my problem by installing https://download.visualstudio.microsoft.com/download/pr/d60aa805-26e9-47df-b4e3-cd6fcc392333/7D7105C52FCD6766BEEE1AE162AA81E278686122C1E44890712326634D0B055E/VC_redist.x64.exe.
Restart your computer after installing it.

Thanks sir...it's help me a lot.

I have installed Kerass and tensorflow on anaconda using

pip install keras

pip install tensorflow

import the keras model then it show the error.... what I do with annaconda
from keras.models import Sequential
C:\ProgramData\Anaconda3\lib\site-packages\keras__init__.py in
4 except ImportError:
5 raise ImportError(
----> 6 'Keras requires TensorFlow 2.2 or higher. '
7 'Install TensorFlow via pip install tensorflow')
8

ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow

if you are working with keras then you need to install Tensorflow version 2.2 using "conda install tensorflow==2.2.0"
you can't use pip in anaconda envirememnt.
At the time of installing tensorflow.....make sure you are in conda envirement.
if you are use normal envirement like VScode then go for "pip install tensorflow==2.2.0"

image

if you are working with keras then you need to install Tensorflow version 2.2 using "conda install tensorflow==2.2.0"
you can't use pip in anaconda envirememnt.
At the time of installing tensorflow.....make sure you are in conda envirement.
if you are use normal envirement like VScode then go for "pip install tensorflow==2.2.0"

not work

I faced a similar issue and I followed this: https://stackoverflow.com/questions/62465620/error-keras-requires-tensorflow-2-2-or-higher and then still had some compatibility issues which were fixed with:
pip install --ignore-installed --upgrade tensorflow==1.6.0
pip install keras==2.1.5

it says
Could not find a version that satisfies the requirement tensorflow==1.6.0 (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 1.15.0rc0, 1.15.0rc1, 1.15.0rc2, 1.15.0rc3, 1.15.0, 1.15.2, 1.15.3, 1.15.4, 2.0.0a0, 2.0.0b0, 2.0.0b1, 2.0.0rc0, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.1.0rc0, 2.1.0rc1, 2.1.0rc2, 2.1.0, 2.1.1, 2.1.2, 2.2.0rc0, 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1)
No matching distribution found for tensorflow==1.6.0

what to do

Oh well, I have solved my problem by installing https://download.visualstudio.microsoft.com/download/pr/d60aa805-26e9-47df-b4e3-cd6fcc392333/7D7105C52FCD6766BEEE1AE162AA81E278686122C1E44890712326634D0B055E/VC_redist.x64.exe.
Restart your computer after installing it.

Thank you soo much! I really needed this

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tvst picture tvst  路  24Comments

tvst picture tvst  路  21Comments

karankharecha picture karankharecha  路  21Comments

DanielDondorp picture DanielDondorp  路  18Comments

monchier picture monchier  路  20Comments