How to fix the error: Cannot load shared library , symbol undefined

How to fix the error: Cannot load shared library , symbol undefined

我有一个 python 脚本,它使用 pyinstaller 转换为 'one file executable'。我电脑中的可执行文件 运行s 没有任何问题。当它在另一台计算机中 运行s 时,其中一个线程似乎在使用 gtk 和 wnck 的地方停止工作。

Failed to load shared library 'libwnck-3.so.0' referenced by the typelib: /usr/lib/x86_64-linux-gnu/libwnck-3.0.so.0: undefined symbol: gdk_display_get_monitor_at_window

一旦可执行文件在另一台计算机的终端中 运行 就会显示上述警告(我猜是在读取导入语句时)。

到达下一行时抛出错误;

screen = Wnck.Screen.get_default()

GLib.GError: g-invoke-error-quark: Could not locate wnck_screen_get_default: /usr/lib/x86_64-linux-gnu/libwnck-3.0.so.0: undefined symbol: gdk_display_get_monitor_at_window (1)

下面的函数在出错的地方被线程化了

import gi
gi.require_version('Wnck', '3.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Wnck

def my_window():
    screen = Wnck.Screen.get_default()  -- this line throws error
    screen.force_update()
    while True:
        time.sleep(.5)
        while Gtk.events_pending():
            Gtk.main_iteration()
        new_window = screen.get_active_window()
        ....
        ....

我正在使用 - Ubuntu 16.04,xenial。 | libgtk-3-0 版本:3.18.9

其他计算机用途 - Ubuntu 18.04.4 bionic | libgtk-3-0 版本:3.22.30

您正在使用的 libwnck 副本是针对包含 gdk_display_get_monitor_at_window() 函数的 GDK 版本编译的,但是您在系统上安装的 GDK 副本不包含此函数.

GTK 3.22 引入了gdk_display_get_monitor_at_window() 功能,因此您必须确保安装了 GDK 3.22 或更高版本。