【发布时间】:2021-12-20 18:13:51
【问题描述】:
所以我正在使用 huggingface 库进行 AI 项目,我需要将其转换为 exe 文件。我使用 PyQt5 作为界面,以及来自 huggingface 的转换器和数据集库。我尝试使用 PyInstaller 将其转换为 exe 文件,它确实完成了项目的 exe 文件的构建,但是当我运行 exe 文件时它给了我这个错误:
Traceback (most recent call last):
File "transformers\utils\versions.py", line 105, in require_version
File "importlib\metadata.py", line 530, in version
File "importlib\metadata.py", line 503, in distribution
File "importlib\metadata.py", line 177, in from_name
importlib.metadata.PackageNotFoundError: tqdm
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "App.py", line 5, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "transformers\__init__.py", line 43, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "transformers\dependency_versions_check.py", line 41, in <module>
File "transformers\utils\versions.py", line 120, in require_version_core
File "transformers\utils\versions.py", line 107, in require_version
importlib.metadata.PackageNotFoundError: The 'tqdm>=4.27' 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 master
[736] Failed to execute script 'App' due to unhandled exception!
[process exited with code 1]
我的代码中的第 5 行是用于导入转换器库的代码。
...
4| from PyQt5.QtCore import QThread, QObject, pyqtSignal
5| from transformers import AutoTokenizer, AutoModelForQuestionAnswering, pipeline
...
...
这是我的 .spec 文件:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['App.py'],
pathex=[],
binaries=[],
datas=[
('./resources/images/logo.png', '.'),
('./resources/model/config.json', '.'),
('./resources/model/pytorch_model.bin', '.'),
('./resources/model/special_tokens_map.json', '.'),
('./resources/model/tokenizer.json', '.'),
('./resources/model/tokenizer_config.json', '.'),
('./resources/model/vocab.txt', '.')
],
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)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='App',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None , icon='logo.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='App')
非常感谢您提供的任何帮助,谢谢 :D
【问题讨论】:
-
看看fbs
-
我试过使用 fbs,它只是给我一个错误,说:
FileNotFoundError: Could not find msvcr100.dll on your PATH.每次我尝试使用fbs freeze构建代码时 -
即使我已经安装了 Visual c++ resdistributable 2012
标签: python pyqt pyside huggingface-transformers