繁体   English   中英

Colorama 和 Pyinstaller

[英]Colorama and Pyinstaller

这是我的问题:我写了一个 python 机器人,它可以制作很多东西,包括打印彩色文本以便更好地理解。 我正在使用 colorama package 因为它甚至在 windows 命令提示符下也能打印颜色。 这是我使用 colorama 的方法,它在 unix 和 windows 上使用 python 3.8:

from colorama import Fore, init
init()
print(Fore.RED + 'some red text') 

现在我的目标是将我的脚本转换为 a.exe,这样它就可以在 windows 上运行而无需任何安装。 问题是,使用 pyinstaller.exe --onefile script.py 或 pyinstaller.exe --onedir script.py 或其他什么,我无法使其工作。 Pyinstaller 成功构建 EXE 并显示 0 错误消息,但每当我启动 exe 时,我都会得到: ModuleNotFoundError: No module named 'colorama'并且它是唯一缺少的模块。 我已经搜索了整个互联网,并没有自己解决这个问题。 你们是我最后的希望! 请帮我

尝试:

pyinstaller.exe --onefile --hidden-import colorama script.py

这个 (--hidden-import colorama) 应该确保 pyinstaller 构建包含 colorama 的应用程序。

你应该首先运行pip/pipenv install colorama

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM