【发布时间】:2018-01-19 08:35:49
【问题描述】:
我可以使用在我的机器上运行的 PyInstaller 创建一个 EXE。我希望EXE真的是独立的,我希望而不是幻想。但是,EXE 不能在其他机器上运行。它因缺少 libvlc.dll 而窒息,错误消息称这可能是由于 PyInstaller 明显无法找到它。我已经用规范文件尝试了几件事,但都无济于事。我没有包含任何代码,因为我认为这无关紧要。这是我的规范文件:
# -*- mode: python -*-
block_cipher = None
added_files = [
( "D:/Applications/Python/Rogues Gallery/images/*.*", "images"),
( "D:/Applications/Python/Rogues Gallery/videos/*.*", "videos"),
( "D:/Applications/Python/MyMediaPlayer/icons/*.*", "icons")
]
a = Analysis(["Rogues_Gallery.py"],
pathex=["D:/Applications/Python/Rogues Gallery/Rogues Gallery",
"C:/Program Files/VideoLAN/VLC/"],
binaries=[("C:/Program Files/VideoLAN/VLC/plugins/*", "plugins"),
("C:/Program Files/VideoLAN/VLC/libvlc.dll", ".")],
datas=added_files,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name="Rogues_Gallery",
debug=True,
strip=False,
upx=False,
runtime_tmpdir=None,
console=True )
在此规范文件上运行 PyInstaller 会生成包含以下行的记帐:
1677 WARNING: One binary added with two internal names.
1677 WARNING: ('libvlc.dll', 'C:\\Program Files\\VideoLAN\\VLC\\libvlc.dll', 'BINARY')
1678 WARNING: was placed previously at
1678 WARNING: ('libvlc.dylib', 'C:\\Program Files\\VideoLAN\\VLC\\libvlc.dll', 'BINARY')
顺便问一下,什么是“dylib”文件?这不是MAC的东西吗?它在我的PC上做什么?实际上,我在我的电脑上找不到“dylib”文件,除非是 PyInstaller 构建的结果;即运行EXE时MEIPASS临时文件夹中有一个libvlc.dylib;还有libvlc.dll。它似乎是 PyInstaller 正在创建的东西。如果我省略(“C:/Program Files/VideoLAN/VLC/libvlc.dll”、“.”),我不会收到警告,并且临时文件中不存在 libvlc.dll。奇怪的是,EXE 继续工作,所以 libvlc.dll 潜伏在某个地方。这就引出了一个问题:“EXE 真的是自给自足的,还是它在自身之外钓鱼,以便从宿主那里得到它所缺乏的东西?”也许,这就是为什么它可以在我的机器上运行,而不是在其他根本没有 libvlc.dll 的计算机上运行。
不管怎样,这里是我的 Rogues Gallery 导入:
try:
import tkinter as tk
import tkinter.ttk as ttk
except ImportError:
import tkinter as tk
import ttk
from tkinter.filedialog import askopenfilename
from tkinter import messagebox
from tkinter.constants import *
from PIL import Image, ImageTk
import os
import sys
import pathlib
import random
from datetime import datetime
import time
import vlc
import MyMediaPlayer
“import vlc”不需要在那里,但我离开了它,因为这正是我一直在运行的方式;它应该出来。 Rogues Gallery 本身不做任何 vlc 的东西。 MyMediaPlayer.py 是我的 Python 脚本。这是所有 vlc 事情发生的地方。以下是它的导入:
try:
import tkinter as tk
import tkinter.ttk as ttk
except ImportError:
import tkinter as tk
import ttk
from tkinter.filedialog import askopenfilename
from tkinter import messagebox
from tkinter.constants import *
from PIL import Image, ImageTk
import os
import sys
import vlc
import pathlib
import atexit
from threading import Thread, Event
import time
import platform
我已经尝试了我能想到的一切。我需要其他更好的思想家。
【问题讨论】:
标签: python windows dll pyinstaller libvlc