首页 > 解决方案 > Heroku 烧瓶应用程序失败:找不到 importlib.util 模块错误

问题描述

我正在尝试使用 Heroku 部署一个烧瓶应用程序,我得到了ModuleNotFoundError. 我不明白为什么,因为我所有的模块都是最新的。有谁知道如何解决这个错误?

CMD 图像

这是我正在使用的代码。代码构建良好,我似乎无法正确部署应用程序。

import pickle
from flask import Flask
from flask import request,jsonify,render_template,abort
import pandas as pd
from sklearn.externals import joblib
import json
import numpy as np
from importlib import util

app = Flask(__name__)

model = pickle.load(open("Final_Gait_Model.sav", "rb"))

@app.route('/')
def home():
    return render_template('index.html')

@app.route('/api', methods=['POST'])
def get_info_predict():

    features = []
    result = request.form

    L_Ank_Force_LHS = float(input('Left Ankle Force at LHS (N): '))
    features.append(L_Ank_Force_LHS)

    L_Ank_Moment_Z_LHS = float(input('Left Ankle Moment (Z-axis) at LHS (Nm): '))
    features.append(L_Ank_Moment_Z_LHS)

    L_Knee_Force_LHS = float(input('Left Knee Force at LHS (N): '))
    features.append(L_Knee_Force_LHS)

    L_Ank_Moment_Y_Stance=float(input('Left Ankle Moment (Y-axis) during stance (Nm): '))
    features.append(L_Ank_Moment_Y_Stance)

    L_Knee_Vel_Y_Stance=float(input('Left Knee Angular Velocity (Y-axis) during stance (deg/s): '))
    features.append(L_Knee_Vel_Y_Stance)

    L_Knee_Vel_Z_Stance=float(input('Left Knee Angular Velocity (Z-Axis) during stance (deg/s): '))
    features.append(L_Knee_Vel_Z_Stance)

    R_Ank_Moment_Y_Stance=float(input('Right Ankle Moment (Y-axis) during stance (Nm): '))
    features.append(R_Ank_Moment_Y_Stance)

    R_Knee_Vel_Y_Stance=float(input('Right Knee Angular Velocity (Y-axis) during stance (deg/s): '))
    features.append(R_Knee_Vel_Y_Stance)

    R_Knee_Vel_Z_Stance=float(input('Right Knee Angular Velocity (Z-axis) during stance (deg/s): '))
    features.append(R_Knee_Vel_Z_Stance)

    R_Ank_Force_RHS=float(input('Right Ankle Force at RHS (N): '))
    features.append(R_Ank_Force_RHS)

    R_Ank_Moment_Z_RHS=float(input('Right Ankle Moment (Z-axis) at RHS (Nm): '))
    features.append(R_Ank_Moment_Z_RHS)

    R_Knee_Force_RHS=float(input('Right Kneed Force at RHS (N): '))
    features.append(R_Knee_Force_RHS)

    features = input_to_one_hot(features)

    prediction = model.predict([features])[0]

    return json.dumps({'Injury Classisfication':prediction});


if __name__ == '__main__':
    app.run(port=8080, debug = True)

标签: pythonheroku

解决方案


推荐阅读