首页 > 解决方案 > 无法使用 tkinter 和 pytorch 模型制作 exe 文件

问题描述

我将 .spec 文件更改如下:

# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
excluded_modules = ['torch.distributions'] # add this
a = Analysis(['sample.py'],
             pathex=['path'],
             binaries=[],
             datas=[],
             hiddenimports=['pkg_resources.py2_warn'], # add this
             hookspath=[],
             runtime_hooks=[],
             excludes=excluded_modules, # add this
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

然后运行:

pyinstaller -F sample.spec

然后我得到了这个错误:

在此处输入图像描述

笔记:

标签: pythontkinterpytorchpyinstallerexe

解决方案


推荐阅读