具有Python-VLC的PyInstaller:无属性"media_player_new"错误 [英] PyInstaller with Python-VLC: No Attribute "media_player_new" Error

查看:37
本文介绍了具有Python-VLC的PyInstaller:无属性"media_player_new"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python-VLC创建视频播放器,并使用PyInstaller在Windows 10计算机上生成可执行文件.最初,它给了我错误:

I'm using Python-VLC to create a video player and PyInstaller to generate the executable file on my Windows 10 machine. Initially, it gave me the error:

Import Error Failed to load dynlib/dll 'libvlc.dll'. Most probably this dynlib/dll was not found when the application was frozen.

为解决此问题,我通过以下方式在.spec文件的二进制文件中添加了丢失的dll:

To solve this issue, I added the missing dlls in the binaries of the .spec file in the following manner:

a = Analysis(['video_player.py'],
             pathex=['C:\\Users\\harsh\\Desktop\\demo\\Video'],
             binaries=[("C:\\Program Files\\VideoLAN\\VLC\\libvlc.dll","."),("C:\\Program Files\\VideoLAN\\VLC\\libvlccore.dll",".")],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

执行完此操作后,我再也不会遇到上述错误.但是,现在出现以下错误:

After doing this, I'm no more getting the above error. However, now I'm getting the following error:

Exception in thread Thread-3:
Traceback (most recent call last):
  File "threading.py", line 914, in _bootstrap_inner
  File "threading.py", line 862, in run
  File "video_player.py", line 100, in vlc_player
AttributeError: 'NoneType' object has no attribute 'media_player_new'

导致此错误的代码是:

i=vlc.Instance('--fullscreen')
p=i.media_player_new()

我已经确保安装了Python-VLC.我在这里还想念其他东西吗?关于如何处理此问题有什么建议吗?

I've made sure that I've installed Python-VLC. Am I missing anything else here ? Any suggestions on how to deal with this issue ?

推荐答案

此问题的一个常见答案是确保您安装了VLC主程序,因为vlc.py依赖于该程序.而且,Python和libvlc.dll都必须是32位,或者都必须是64位.

One common answer to this problem is to make sure you have the VLC main programme installed, as the vlc.py relies on it. And also, that Python and the libvlc.dll both have to be 32-bit, or, both have to be 64-bit.

这篇关于具有Python-VLC的PyInstaller:无属性"media_player_new"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆