linux下使用python打开terminal时报错
2023-04-18 15:45:22 时间
场景一:在jenkins上执行自动化任务,测试任务执行时使用jenkins用户(有sudo权限),测试脚本在linux执行(后台),执行到以下代码时报错:
os.system(f"/usr/bin/konsole -e {cmd_orin2_10s}")
场景二:测试脚本在本地执行没有问题,本地执行时使用root用户,可正常打开命令窗口
错误日志:
17:44:03 qt.qpa.xcb: could not connect to display 17:44:03 qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. 17:44:03 This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. 17:44:03 17:44:03 Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
解决方法:
从场景1和场景2可对比出,应该是由环境变量引起。从环境变量已经显示窗口这两方面去查找问题,可找到 export DISPLAY=":0.0"
参考文档:
相关文章
- python whl文件怎么安装
- python index函数是什么
- python中pass占位符用法
- python input函数是什么
- Python pass函数是什么
- Python float函数怎么用
- python ctypes是什么
- Python 交叉验证模型评估
- python中的class是什么
- Python pop是什么
- python check函数是什么
- python insert函数是什么
- python怎么调用random
- Python中创建Dataframe的四种方法
- 怎样用jupyter运行py文件?
- python中如何重复打印很多遍?
- python中字典items()函数如何使用?
- Python中Impala的使用
- python bg是什么
- python time模块是什么