我的工作流程在实验环境中运行得很完美,但在部署到Web服务后,发送请求时收到了这个错误。
Python代码:
# -*- coding: utf-8 -*-#import sysimport pickleimport pandas as pdfrom sklearn.tree import DecisionTreeClassifierfrom sklearn import tree def azureml_main(dataframe1 = None, dataframe2 = None): print('input dataframe1 ',dataframe1) decision_tree_pkl_predictive_maint = r'.\Script Bundle\decision_tree_pkl_predictive_maint.pkl' #sys.path.insert(0,".\Script Bundle") #model = pickle.load(open(".\Script Bundle\decision_tree_pkl_predictive_maint.pkl", 'rb')) modle_file = open(decision_tree_pkl_predictive_maint,"rb") model = pickle.load(modle_file) #return the mode of prediciton result = model.predict(dataframe1) print(result) result_df = pd.DataFrame({'prediction_class':result}) return result_df,
错误信息:
执行Python脚本RRS时出现错误0085:在脚本评估期间发生以下错误,请查看输出日志以获取更多信息:———- Python解释器错误消息开始 ———- 在执行函数时捕获到异常:Traceback (most recent call last): File “\server\InvokePy.py”, line 120, in executeScript outframe = mod.azureml_main(*inframes) File “\temp-1036260731852293620.py”, line 46, in azureml_main modle_file = open(decision_tree_pkl_predictive_maint,”rb”) FileNotFoundError: [Errno 2] 没有这样的文件或目录:’.\Script Bundle\decision_tree_pkl_predictive_maint.pkl’ ———- Python解释器错误消息结束 ———-
请提供建议。
回答:
问题与您的文件路径有关。请确保您使用了正确的路径。