我正在尝试为这个项目生成一个适用于 macOS 的软件包。存储库中的 .spec 文件在 Windows 上运行良好,但当我尝试将其用于 macOS 时,它失败了。我已尝试通过以下方式修复 MacOS 版本
我正在尝试为 这个项目 。 .spec
存储库中的文件在 Windows 上运行良好,但当我尝试将其用于 macOS 时,它失败了。
我尝试通过修改它来修复 MacOS 的问题,结果如下:
# -*- mode: python ; coding: utf-8 -*-
import os.path
from pathlib import Path
from PyInstaller.compat import is_darwin, is_win
from PyInstaller.utils.hooks import copy_metadata, collect_data_files, collect_all
datas = []
datas += collect_data_files("transformers", include_py_files=True)
datas += collect_data_files("lightning")
datas += collect_data_files("lightning_fabric")
datas += collect_data_files("speechbrain")
datas += collect_data_files("pyannote")
datas += collect_data_files("asteroid_filterbanks")
datas += collect_data_files("whisperx")
datas += collect_data_files("librosa")
datas += copy_metadata("tqdm")
datas += copy_metadata("regex")
datas += copy_metadata("requests")
datas += copy_metadata("packaging")
datas += copy_metadata("filelock")
datas += copy_metadata("numpy")
datas += copy_metadata("tokenizers")
datas += copy_metadata("pillow")
datas += copy_metadata("huggingface_hub")
datas += copy_metadata("safetensors")
datas += copy_metadata("pyyaml")
datas += [("res", "res")]
datas += [("config.ini", ".")]
datas += [(".env", ".")]
datas += [("venv/lib/python3.10/site-packages/customtkinter", "customtkinter")]
datas += [("venv/lib/python3.10/site-packages/torch", "torch")]
datas += [("venv/lib/python3.10/site-packages/torchgen", "torchgen")]
datas += [("venv/lib/python3.10/site-packages/speech_recognition", "speech_recognition")]
datas += [("venv/lib/python3.10/site-packages/moviepy", "moviepy")]
datas += [("venv/lib/python3.10/site-packages/dotenv", "dotenv")]
datas += [("venv/lib/python3.10/site-packages/openai", "openai")]
hiddenimports = [
"huggingface_hub.repository",
"pytorch",
"sklearn.utils._cython_blas",
"sklearn.neighbors.typedefs",
"sklearn.neighbors.quad_tree",
"sklearn.tree",
"sklearn.tree._utils",
"darkdetect",
"tkinter.font",
"tkinter.ttk",
"cmath",
"pickletools",
"unittest.mock",
"aifc",
"proglog",
"imageio",
"decorator",
]
block_cipher = None
debug = True
if debug:
options = [("v", None, "OPTION")]
else:
options = []
a = Analysis(
["src/app.py"],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
macos_icon = "res/macos/icon.icns"
windows_icon = "res/windows/icon.ico"
exe = EXE(
pyz,
a.scripts,
options,
exclude_binaries=True, #NEW
name="Audiotext",
debug=debug,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=debug,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file="res/macos/entitlements.plist" if is_darwin else None,
icon=windows_icon if is_win else macos_icon,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name="Audiotext",
)
app = BUNDLE(
coll,
name="Audiotext.app",
icon=macos_icon,
bundle_identifier="com.henestrosadev.audiotext",
version="2.3.0",
info_plist={
"NSPrincipalClass": "NSApplication",
"NSAppleScriptEnabed": False,
"NSHighResolutionCapable": True,
"NSMicrophoneUsageDescription": "Allow Audiotext to record audio from your microphone to generate transcriptions.",
}
)
现在,它生成了包,但是当我打开生成的文件时,我总是得到一个 ModuleNotFoundError
。例如,我现在遇到的错误是 ModuleNotFoundError: No module named 'openai'
。我通过添加此行修复了它,就像我对之前缺失的其余模块所做的那样:
datas += [("venv/lib/python3.10/site-packages/openai", "openai")]
现在,我得到的错误是 ModuleNotFoundError: No module named 'pydantic'
。有些地方不对劲,因为手动添加程序的所有包是没有意义的。