简体   繁体   English

Pyinstaller exe文件不接受任何输入

[英]Pyinstaller exe file doesn't take any input

I want to create.exe file from.py.我想从 .py 创建 .exe 文件。 If I run.py file it works well and I have no problem with it.如果我运行 .py 文件,它运行良好,我没有问题。 But when I run.exe file created by pyinstaller I can not input(type) anything in command line.但是当我运行由 pyinstaller 创建的 exe 文件时,我无法在命令行中输入(键入)任何内容。

I have tried a several options already - onefile execuatable(--onefile), disable upx(--noupx).我已经尝试了几个选项 - onefile execuatable(--onefile),禁用 upx(--noupx)。 Both give no improvements at all.两者都没有任何改进。

Is it a problem that I importing my own libs?我导入自己的库有问题吗? Better to paste functions I use inside my.py file?最好将我使用的函数粘贴到 my.py 文件中?

from PIL import Image
import numpy as np
from convetai.cropImage import cropImage, step
def main():
    path = input()
    img = np.array(Image.open(f"{path}"))

    print("Your image has a shape of ", img.shape)
    n = int(input("Enter number of divisions."))
    #dx, dy = step(n, img.shape)
    i = int(input("Enter num of row"))
    j = int(input("Enter num of column"))
    n_img = cropImage(img, n, i, j, save=True)
    print("Done.")

if __name__ == '__main__':
    main()

Thank You.谢谢你。

Since there is input() method you should use the console option when converting to exe file.由于有input()方法,因此在转换为 exe 文件时应使用控制台选项。 GUI will not work. GUI 将不起作用。 try the code below试试下面的代码

pyinstaller --noconfirm --onefile --console test_Script.py 

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

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