pyinstaller 打包的执行文件在另一台机子上运行出错,错误如下:
[root@hubrhel# ./main
Traceback (most recent call last):
File "main.py", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
File "tkinter/__init__.py", line 36, in <module>
ImportError: /tmp/_MEIICfyah/libX11.so.6: undefined symbol: xcb_poll_for_reply64
[13720] Failed to execute script main
解决方式如下:
Pyinstaller excludes the libxcb libraries. Check PyInstaller/depend/dylib.py - there you will find:
libxcb changes ABI frequently (e.g.: between Ubuntu LTS releases) and is libxcb-dri changes ABI frequently (e.g.: between Ubuntu LTS releases) and is usually installed as dependency of the graphics stack anyway. No need to bundle it.
... or check this commit, which has not made it into pyinstaller yet:https://github.com/pyinstaller/pyinstaller/commit/4a6d74a13122b763e99f97995fbbb1c6967769bb
Try to remove "r'/libxcb.so..*': 1," in PyInstaller/depend/dylib.py.
去除PyInstaller/depend/dylib.py文件中的libxcb.so相关的两个库 r'libxcb\.so(\..*)?',r'libxcb-dri.*\.so(\..*)?'
然后重启设备,重新进行打包。程序运行正常。