一、问题
- PHP调用Python报错:
: Unable to open file (unable to open file: name = './model/char_judgement.h5', errno = 2, error message = 'No such file or directory' - 但CMD直接运行Python没有错误
二、原因
PHP调用Python需要使用绝对路径,不能使用相对路径
三、解决
将Python中的所有相对路径改为绝对路径
四、思考
- 降低Python程序对不用平台的适应性,增加调试难度;
- 后期考虑去掉PHP,直接使用Flask或者使用绝对路径作为变量进行传递,可以在一定程度上解决问题