首页 > 解决方案 > Pyinstaller 没有名为 'pyfiglet.fonts ' pyinstaller ' 的模块

问题描述

嘿,我想用 Pyinstaller 导出我的 Python Selenium Projekt,但是每次当我尝试这样做时它都会出错,但是当我启动 exe 文件时,我变成了这个错误:

ModuleNotFoundError: no module named 'pyfiglet.fonts'

要启动 pyinstaller,我使用了以下命令:

pyinstaller --onefile SickoAIO.py

标签: pythonseleniumpyinstaller

解决方案


没有更多信息,很难判断出什么问题。但是,我将假设您没有说明的一些事情并提供一些想法:

  1. 在您尝试使用 pyinstaller 之前假设 SickoAIO.py 工作正常,有时如果在您的 Python 代码中您只导入了更通用的模块:
import pyfiglet

但需要使用 pyfiglet.fonts,让它在 pyinstaller 中工作的“hack”可能是使导入更具体:

import pyfiglet.fonts

我没有使用过 pyfiglet,但是这个 hack 对我有用 numpy 模块,例如。

  1. 帮助我解决与 numpy、scipy 等类似问题的另一件事是更新模块和/或 pyinstaller 的版本

  2. 您可能需要使用钩子,尤其是因为 pyfiglet 似乎无法与 pyinstaller 配合使用。这在此处专门针对 pyfiglet 进行了解释: https ://hugomartins.io/essays/2019/06/pyinstaller-pyfiglet-trouble/ 我没有尝试过,看起来您可能需要单击该网页中的更多链接以及了解更多关于钩子如何在 pyinstaller ( https://pyinstaller.readthedocs.io/en/stable/hooks.html?highlight=hook ) 中工作以了解完整问题。


推荐阅读