Huvi
Huvi

Reputation: 83

Pyinstaller exe file doesn't take any input

I want to create .exe file from .py. If I run .py file it works well and I have no problem with it. But when I run .exe file created by pyinstaller I can not input(type) anything in command line.

I have tried a several options already - onefile execuatable(--onefile), disable 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?

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.

Upvotes: 6

Views: 8505

Answers (3)

Anonymous
Anonymous

Reputation: 1

I found that if you just don't disable the command prompt it works fine

Upvotes: 0

Abhishek Verma
Abhishek Verma

Reputation: 11

My recommendation is to use pyinstaller to make exe and whenever you need input in your program, just use tkinter.

Example:

import tkinter as tk from tkinter import simpledialog for features in 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)

Now you can use USER_INP in whatever fasion you want

Upvotes: 1

Shinto Joseph
Shinto Joseph

Reputation: 3103

Since there is input() method you should use the console option when converting to exe file. GUI will not work. try the code below

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

Upvotes: 7

Related Questions