Closed whitePythonLearn closed 1 year ago
补充一下,单个执行RobotListener.py,日志生成是正常的。 我的是robotframework项目,发生错误的操作是执行了robotframework的执行命令: D:\Python39\Scripts\robot.exe --listener D:\robotframework_smartHub3.0\rf_smarthub3.0\python_files\RobotListener.py -d D:\robotframework_smartHub3.0\rf_smarthub3.0 D:\robotframework_smartHub3.0\rf_smarthub3.0\smartHub\测试数据构造\测试数据构造.robot
D:\Python39\Scripts\robot.exe\nb_log_config.py 这种就是sys.path[1]识别错误,因为你打包成exe了,sys.path[1]发生了变化。
你自己使用PYTHONPATH或者sys.path.insert来使nb_log_config.py在sys.path的文件夹列表中的任何一个文件夹下面的位置就行了。
failed: Importing listener 'D:\robotframework_smartHub3.0\rf_smarthub3.0\python_files\RobotListener.py' failed: FileNotFoundError: [Errno 2] No such file or directory: 'D:\Python39\Scripts\robot.exe\nb_log_config.py' 执行文件RobotListener.py调用mylog.py mylog.py: 项目结构: