我想从 .py 创建 .exe 文件。如果我运行 .py 文件,它运行良好,我没有问题。但是当我运行 pyinstaller 创建的 .exe 文件时,我无法在命令行中输入(键入)任何内容。
我已经尝试了几个选项 - onefile execuatable(--onefile),禁用 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()
谢谢。
最佳答案
因为有 input() 方法,所以在转换为 exe 文件时应该使用控制台选项。 GUI 将不起作用。试试下面的代码
pyinstaller --noconfirm --onefile --console test_Script.py
关于python - Pyinstaller exe文件不接受任何输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58523628/