.exe 文件显示错误 input(): 丢失 sys.stdin

问题描述 投票:0回答:2

我正在使用

pyinstaller
.py
文件转换为
.exe
文件

我的

terminal2.py
文件是:

import sys

if __name__ == "__main__":
    arg = sys.argv
    name = input("Enter your name..")
    print(f"hello, {name}")

然后在文件目录的终端中运行以下命令:

pyinstaller --onefile -w terminal2.py

changes in the directory after the above command

error when I run the .exe file inside the dist directroy

我在谷歌上寻求帮助,但没有成功。

我想要实现什么?

最低期望:当我双击terminal2.exe文件时,cli将打开,我将能够根据我的python代码执行通常的输入和输出操作。
更多期望:我可以创建像

pip
这样的命令,可以从任何
cmd/terminal

全局运行
python pyinstaller exe
2个回答
5
投票

试试这个:

pyinstaller --onefile terminal2.py

更多详情:

https://datatofish.com/executable-pyinstaller/


0
投票

RuntimeError: input(): lost sys.stdin

我使用

--noconsole
参数作为:

pyinstaller --onefile --noconsole ScrCpy_GUI.py

由于没有控制台,因此无法从用户那里获取

input()

尝试(根据您的情况):

pyinstaller --onefile terminal2.py
© www.soinside.com 2019 - 2024. All rights reserved.