I am getting error while importing flask, error message goes as
ImportError: cannot import name 'abort' from 'werkzeug.exceptions'
here is my full code
from flask import Flask,render_template,request,jsonify
from sklearn.preprocessing import StandardScaler
import pickle
app=Flask(__name__)
@app.route('/',methods=['GET','POST'])
def homepage():
print("home")
return render_template("Index.html")
@app.route('/predict',methods=['POST'])
def predict():
print("predict")
preg=int(request.form["PreganciesName"])
glucose=float(request.form["GlucoseName"])
BP=float(request.form["BloodPressureName"])
st=int(request.form["SkinThicknessName"])
insu=float(request.form["InsulinName"])
bmi=float(request.form["BMIName"])
dpf=float(request.form["DPFName"])
age=int(request.form["ageName"])
print("fetching data done")
scaler=StandardScaler()
filename = 'Diabetis with logistic regression.pickle'
loaded_model = pickle.load(open(filename, 'rb'))
print("model loded")
a = loaded_model.predict(scaler.transform([[preg,glucose,BP,st,insu,bmi,dpf,age]]))
print("otput "+str(a))
return render_template('result.html',a[0])
if __name__=="__main__":
app.run(debug=True)
I guess problem was with python 3.8 version. I reinstalled python 3.6 and it worked. I think it will also work fine for python 3.7
There is no import of abort
in the code that you posted.
However, have a look where the error is raised and replace the abort
that you're wrongly importing with:
from flask import abort
I had the same error message for the flask package for python2.7 and it vanished when I tried:
sudo apt-get install python-flask
This solution can be generalised, see Python error "ImportError: No module named" .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.