PySide2是QT官方出的Python的QT封裝, 不過默認安裝運行時候會有一些小問題, 可能是系統里已經安裝過其他版本QT的原因, 會報錯如下:
PySide2 qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, xcb.
可以通過添加環境變量來解決:
envpath = '/home/ckboss/anaconda3/lib/python3.6/site-packages/PySide2/Qt/plugins/platforms' os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = envpath