python - 使用 pyinstaller 转换为 .exe 时,简单的打印语句在 python .py 中不起作用
问题描述
Python 文件包含一行打印语句
#file1.py
print("python to exe")
在windows环境下使用pyinstaller库成功将.py文件转换为.exe,得到可执行文件'file1.exe'
pyinstaller --onefile -w 'file1.py'
尝试在命令行提示符下执行“file1.exe” ,.exe 既不打印也不显示任何错误。任何帮助表示赞赏
解决方案
这是因为您使用的是“-w”选项。在 Windows 上,这将在运行程序时禁用控制台窗口。从 pyinstaller 文档中:
-w, --windowed, --noconsole
Windows and Mac OS X: do not provide a console window for standard i/o. On Mac OS X this also triggers building an OS X .app bundle. On Windows this option will be set if the first script is a ‘.pyw’ file. This option is ignored in *NIX systems
推荐阅读
- bash - 从文件bash替换字符串中的点
- stl - 通过 gdb 将 c++ 变量传递给 python
- python - 来自 sklearn 的 Graphviz 找不到我的文件?
- r - 使用 ggplot2 将标题和另一条线添加到折线图
- sql - 在postgresql中随机化没有时区的时间戳
- xero-api - 我可以将 Stitch 与多个 Xero 帐户一起使用吗?
- mysql - 仅当记录列匹配三个条件时才显示 DISTINCT user_id
- javascript - 使用节点 JS 读取 pdf 文件
- sql - 仅检索我在另一个表中没有的用户
- c# - 如何在 ListView Visual Studio 中加载对象类型数据