I am using python 3.11.11 version. i have installed tensorflow through pip install tensorflow in env virtual environment.
when i try to run app.py file in flask deploy method. the console running provide the following error message:
from tensorflow.python.trackable.data_structures import ListWrapper ModuleNotFoundError: No module named 'tensorflow
In python anywere error message:
2025-05-05 06:22:23,221: Expected: input_layer_3
2025-05-05 06:22:23,221: Received: inputs=(('Tensor(shape=(1, 7))',),)
2025-05-05 06:22:23,221: warnings.warn(msg)
the app.py file format is:
import numpy as np
from flask import Flask, request, render_template
import pickle
# import keras
# from sklearn.preprocessing import StandardScaler
# from keras.models import Sequential
# import tensorflow
# from keras.layers import Dense, Dropout
# from tensorflow.python.keras.models import Sequential
# from tensorflow.python.keras.layers import Dense, Dropout
# Create flask app
app = Flask(__name__)
model = pickle.load(open("model.pkl", "rb"))
@app.route("/")
def Home():
return render_template("index.html")
@app.route("/predict", methods=["POST"])
def predict():
float_features = [[float(x) for x in request.form.values()]]
features = [[np.array(float_features)]]
# input_data = np.array([[a, b, c, d, e, f, g]])
prediction = model.predict(features)
# prediction = model.predict(input_data)
output = np.round(prediction[0])
return render_template("after.html", data=output)
if __name__ == "__main__":
app.run(debug=True)
[edit by admin: formatting]