python - Heroku 烧瓶应用程序失败:找不到 importlib.util 模块错误
问题描述
我正在尝试使用 Heroku 部署一个烧瓶应用程序,我得到了ModuleNotFoundError
. 我不明白为什么,因为我所有的模块都是最新的。有谁知道如何解决这个错误?
这是我正在使用的代码。代码构建良好,我似乎无法正确部署应用程序。
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)
解决方案
推荐阅读
- rx-java - 使用 Vert.x 和 RxJava 读取行
- numpy - 使用 keras 和预训练的 pspnet50 进行图像分割
- firebase - 使用 Google Domains 托管 Firebase:mydomain.com 有效,www.mydomain.com 无效
- graphviz - 两个子图中的相同节点
- php - 代码问题不起作用,不确定我的语法是否关闭或我遗漏了什么
- python - AttributeError:“函数”对象在 Pytest Mock 中没有属性
- css - 悬停时转换比例按钮(引导程序)
- mysql - 方法 Illuminate\Database\Eloquent\Collection::paginate 不存在。”
- ios - 是否可以在 UICollectionViewCell 中设置 Swift UI 视图?
- spark-ar-studio - 如何在 spark ar 中使用 cameraTexture 进行背景分割?