Unable to open file (unable to open file: name = './model/char_judgement.h5', errno = 2, error message = 'No such file or directory'

一、问题

  1. PHP调用Python报错:
    : Unable to open file (unable to open file: name = './model/char_judgement.h5', errno = 2, error message = 'No such file or directory'
  2. 但CMD直接运行Python没有错误

二、原因

PHP调用Python需要使用绝对路径,不能使用相对路径

三、解决

将Python中的所有相对路径改为绝对路径

四、思考

  1. 降低Python程序对不用平台的适应性,增加调试难度;
  2. 后期考虑去掉PHP,直接使用Flask或者使用绝对路径作为变量进行传递,可以在一定程度上解决问题

你可能感兴趣的:(Unable to open file (unable to open file: name = './model/char_judgement.h5', errno = 2, error message = 'No such file or directory')