我一直在尝试使用 pyinstaller 将我的 pthon 脚本转换为独立的 exe,问题是我需要包含 python-vlc 并且当我运行时
pyinstaller --add-binary "E:\Documents\Spotify Posters\Spotify Poster Coding Shit\libvlc.dll;." --add-binary "E:\Documents\Spotify Posters\Spotify Poster Coding Shit\libvlccore.dll;." --onefile test3.py
我收到错误
Traceback (most recent call last):
File "test3.py", line 1120, in <module>
main()
File "test3.py", line 1116, in main
app = SpotifyPosterApp(root)
^^^^^^^^^^^^^^^^^^^^^^
File "test3.py", line 108, in ~init~
self.backgroundplayer = vlc.MediaPlayer(BACKGROUNDVIDEO_PATH)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "vlc.py", line 3287, in __new
AttributeError: 'NoneType' object has no attribute 'media_player_new'
[32308] Failed to execute script 'test3' due to unhandled exception!
如果我不包含二进制文件,代码将在我的主电脑上作为 exe 运行,但我需要它,以便代码可以传输到多台电脑,当我包含二进制文件时,我会收到上述错误,任何帮助都是非常感谢你
我很确定
--add-data
和 --add-binary
采用格式 SOURCE:DEST
,这意味着分隔符是冒号 (:
),而不是分号 (;
)。尝试使用相对路径。
例如假设您从文件夹运行安装程序
Spotify Posters
pyinstaller --add-binary "Spotify Poster Coding Shit\libvlc.dll:." --add-binary "Spotify Poster Coding Shit\libvlccore.dll:." --onefile test3.py