python - 尝试运行使用 pyinstaller 创建的 Mac 应用程序时,“加载 Python 库时出错”...“找不到图像错误”是什么意思?
问题描述
Mac Big Sur 上的 Python 3.9 使用最新版本的 pyinstaller。
我有一个正常运行的脚本名称Read_CSV_Barplot.py
,我想使用 pyinstaller 将其制成 .app。运行 pyinstaller 时,我收到一些警告,但没有错误消息。下面是我的 .spec 文件,我在其中修改了 pathex 以包含存储所需模块的目录 site-packages。尝试在终端上运行生成的 .app 时,我收到以下错误消息,我正在尝试破译:
Error loading Python lib '/Users/fishbacp/Desktop/dist/Read_CSV_Barplot.app/Contents/MacOS/Python': dlopen:
dlopen(/Users/fishbacp/Desktop/dist/Read_CSV_Barplot.app/Contents/MacOS/Python, 10): image not found
这是 .spec 文件:
block_cipher = None
a = Analysis(['Read_CSV_Barplot.py'],
pathex=['/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages', '/Users/fishbacp/Desktop'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
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)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='Read_CSV_Barplot',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='Read_CSV_Barplot')
app = BUNDLE(exe,name='Read_CSV_Barplot.app',icon=None,bundle_identifier=None)
我以前从未遇到过这种类型的错误消息,这就是我的困惑所在。
解决方案
根据https://github.com/pyinstaller/pyinstaller/issues/2047上的帖子,我在我的规范文件中更改exe
为在 Bundle 内。coll
尝试运行新应用程序时,我遇到了不同的错误消息,“_tkinter 无法找到。” 我纠正了这个使用brew install python-tk
现在一切正常。
推荐阅读
- javascript - 您将如何将食谱存储在 json 中?
- scala - cat.sequence 在所有 Futures 完成之前执行,即使提升到 EitherT
- javascript - 如何将祖父组件中的函数传递给 ReactJs 中的孙子组件?
- flutter - 当我单击标记相机时颤动未居中
- flutter - 使用图像选择器访问图库时如何显示图片?
- android - Android Room - 使用事务从两个实体中删除
- xcode - 在 Xcode 中设置自定义 UITextView 委托的委托
- python - 如何使用 Python 转换数据框中的日期格式?
- python - 通过复杂的转置或子设置操作创建新的 pandas 数据帧
- docker - 如何使用 docker-compose.yml 在映射为卷的目录中克隆 GitHub 存储库?