我想从.py文件创建.exe文件。如果我运行.py文件,它可以正常工作,没有问题。但是当我运行用pyinstaller创建的.exe文件时,在命令行中无法输入(键入)任何内容。
我已经尝试了几个选项 - 单文件可执行文件(--onefile),禁用upx(--noupx)。但都没有改善。
我导入自己的库是否有问题?最好将我使用的函数粘贴到我的.py文件中吗?
我已经尝试了几个选项 - 单文件可执行文件(--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()
谢谢。
--console
开关另外,从-D
选项开始。只有在使用 onedir 选项正常工作后,才应继续使用--onefile
也许在path = input()
之前加入一个打印语句,并改为以下形式:path = input("请输入路径:")
以便更好地进行调试。告诉我们你在这些更改后在控制台上看到的确切内容。 - gelonidapyinstaller --onedir --console script.py
时,没有任何变化。我运行 dist\script\script.exe 文件,它打开 cmd 窗口约半秒钟,然后就关闭了。我还添加了path = input("Enter the path")
。 - Huviimport numpy.random.common,import numpy.random.bounded_integers, import numpy.random.entropy
来解决。 :) 谢谢! - Huvi