numpy Pyinstaller exe文件不接受任何输入

sqougxex  于 2023-03-23  发布在  其他
关注(0)|答案(2)|浏览(125)

我想从. py创建.exe文件。如果我运行.py文件,它工作得很好,我没有问题。但当我运行由pyinstaller创建的.exe文件时,我无法在命令行中输入(键入)任何内容。
我已经尝试了几个选项- onefile executable(--onefile),disable upx(--noupx).这两个都给予任何改进。
我导入自己的库有问题吗?最好把我使用的函数粘贴到我的.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()

谢谢你。

fzwojiic

fzwojiic1#

由于有***input()***方法,您应该使用控制台选项时转换为exe文件。GUI将无法工作。尝试下面的代码

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

vs91vp4v2#

我的建议是使用pyinstaller来制作exe,每当你需要在程序中输入时,就使用tkinter。
示例:
从tkinter导入tkinter作为tk导入FeatureList中特征的简单对话框:

ROOT = tk.Tk()

ROOT.withdraw()
# the input dialog
USER_INP = simpledialog.askstring(title="User Input",
                                  prompt="Do You want to Continue")
# check it out
print("Continuing", USER_INP)

现在你可以在任何你想要的风格中使用USER_INP

相关问题