vlc.Instance: 属性错误("module 'vlc' has no attribute 'Instance'")

vlc.Instance: AttributeError("module 'vlc' has no attribute 'Instance'")

我正在努力使 VLC 播放器能够正确导入,从而连续播放一系列 VLC 媒体文件。但是,我似乎无法正确导入 VLC!我已经下载了 vlc.py 并将其添加到我的工作区。看起来像这样;

import vlc

class PlayerWindow(Frame):

    def __init__(self, parent):

        super().__init__()



        self.parent = parent

        self.parent.attributes('-alpha', 0)

        self.parent.attributes("-fullscreen", True)

        self.parent.bind_all("<Key>", self.key)



        # VLC player controls

        self.Instance = vlc.Instance()

        self.player = self.Instance.media_player_new()

        self.player.toggle_fullscreen()

        self.player.video_set_key_input(False)



        self.parent.update()

我正在使用 Microsoft VS 2017

尝试卸载 vlc (pip uninstall vlc) 和重新安装的组合。 python-vlc 也一样。还要检查您的路径变量是否已设置(VS Code 和 VideoLAN\VLC )。那它一定能用。

在我的例子中,通过在 linux

上安装 libvlc-dev 解决了这个问题