pyinstaller "importlib.metadata.PackageNotFoundError"

使用pyinstaller 打包后的python 程序,执行的时候出现 "importlib.metadata.PackageNotFoundError" 异常

Traceback (most recent call last):
  File "main.py", line 5, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "util/convert.py", line 12, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "whisper/__init__.py", line 12, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "whisper/decoding.py", line 11, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "whisper/tokenizer.py", line 8, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "transformers/__init__.py", line 30, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "transformers/dependency_versions_check.py", line 41, in <module>
  File "transformers/utils/versions.py", line 123, in require_version_core
  File "transformers/utils/versions.py", line 110, in require_version
importlib.metadata.PackageNotFoundError: No package metadata was found for The 'regex!=2019.12.17' distribution was not found and is required by this application. 
Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git main

因为有些依赖包是间接在其他包里被调用,用pyinstaller 打包的时候默认不会包括这些间接调用的依赖包进去,所以我们可以使用 参数 --copy-metadata 手动添加模块的打包,例如 --copy-metadata tqdm 。

pyinstaller main.py --clean -F -c --noconsole --copy-metadata tqdm --copy-metadata regex \ --copy-metadata requests --copy-metadata packaging --copy-metadata filelock

转载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值