Aug-07-2019, 02:29 PM
My desperate attempt to find a solution....
I am trying to compile an .EXE on Windows 10 64-bit with PyInstaller. When using the following CMD in Windows CMD prompt, I get a successful execution of the script:
This occurs due to -w or --onefile i believe. Script runs fine without --onefile.
I call my script and pass arguments via cmd line. 2 of the arguments are paths and i use relative path:
I am trying to compile an .EXE on Windows 10 64-bit with PyInstaller. When using the following CMD in Windows CMD prompt, I get a successful execution of the script:
pyinstaller --onefile Mainscript.pyThis works fine executing from CMD prompt with arguments (see Python code below). However, the console appears when executing. So, I re-compile to .exe with the following CMD...
pyinstaller --noconsole --onefile Mainscript.pyNow, when running my program via cmd line with arguments, i get "Failed to Execute Script" and i am wondering why.
This occurs due to -w or --onefile i believe. Script runs fine without --onefile.
I call my script and pass arguments via cmd line. 2 of the arguments are paths and i use relative path:
start MainScript.exe "TestPDF.pdf" "TestJPG.jpg" 100Here is script:
#REQUIRES PDF2IMAGE INSTALLED WITH PIP #REQUIRES POPPLER BINARIES INSTALLED ON WINDOWS VIA WEBSITE from pdf2image import convert_from_path import os.path import ctypes import sys try: argcount = len(sys.argv) #COUNT OF CMD LINE ARGUMENTS if argcount != 4: if argcount == 1: errStr = "No arguments passed" else: errStr = "Error: incomplete args passed. " + "Args = " + str(argcount) for x in range(1, argcount): #argv[0] IS ALWAYS THE SCRIPT NAME errStr = errStr + str(x) + ": " + sys.argv[x] + "\n" ctypes.windll.user32.MessageBoxW(0, errStr, "Python Convert2Thumbnail", 1) else: inpath = sys.argv[1] outpath = sys.argv[2] fsize = sys.argv[3] pages = convert_from_path(inpath, fsize) firstpage = pages[0] firstpage.save(outpath, 'JPEG') except Exception as e: errmsg = getattr(e, 'message', repr(e)) for x in range(1, argcount): errStr = errStr + str(x) + ": " + sys.argv[x] + "\n" errStr = errStr + "\n" + "\n" + errmsg ctype