cygwin环境下找不到libvlc_new的解决方案

python3.8.3
win 10 需要安装vlc-3.0.11-win64.exe,假如安装在C:\Program Files\VideoLAN\VLC目录下
修改cygwin python3.8.3安装目录下的vlc.py文件

找到find_lib()函数,增加一个平台类型判断分支,如下代码:

elif sys.platform.startswith('cygwin'):
        # try some standard locations.
        libname = 'libvlc.dll'
        vlcDllDir = '/cygdrive/c/Program Files/VideoLAN/VLC/'
        if os.path.exists(vlcDllDir):
            plugin_path = os.path.dirname(vlcDllDir + libname)
        
        if plugin_path is not None:  # try loading
             # PyInstaller Windows fix
            if 'PyInstallerCDLL' in ctypes.CDLL.__name__:
                ctypes.windll.kernel32.SetDllDirectoryW(None)
            p = os.getcwd()
            os.chdir(plugin_path)
             # if chdir failed, this will raise an exception
            dll = ctypes.CDLL('.\\' + libname)
             # restore cwd after dll has been loaded
            os.chdir(p)
        else:  # may fail
            dll = ctypes.CDLL('.\\' + libname)

当然这个不是最好的解决方案,没办法,我刚学python,很多模块用的还不熟悉。

You may also like...

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据