1

I am currently working on making a Python IDLE, I am giving an option to convert the python file to an executable file (.exe). But I get a Pyinstaller Error.

I imported:

import os
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.font as tkFont
from tkinter import filedialog
from tkinter import messagebox

I defined the root variable. Below is a toplevel of the root.

I had tried:

def compile2():
    def compile(event):
        realico = ico.get()
        l = " --icon=\"%s\"" % realico
        texta = "pyinstaller"
        if onefile:
            texta += " --onefile"
        if windowed:
            texta += " --windowed"
        texta += l
        texta += " " + file.name
        textb = texta
        print(texta)
        while True:
            if textb[-1] != "/":
                textb = textb[:-1]
            else:
                break
        i = 0
        while i != 41:
            i += 1
            textb = textb.replace(textb[0], '', 1)
        textb = str(textb)
        texta = rreplace(texta, textb, '', 1)
        os.system("cd %s" % textb)
        sure = messagebox.askyesno(title="Python Code Editor", message="This requires to download a Python Package to your computer.\nAre you sure?")
        if sure:
            os.system("pip install pyinstaller")
            messagebox.showinfo(title="Python Code Editor", message="The package has downloaded.")
            os.system(texta)
        else:
            messagebox.showinfo(title="Python Code Editor", message="The package did not download.")
    file = filedialog.askopenfile(defaultextension=".py", filetypes=[("Python Files", "*.py")])
    new = tk.Toplevel(root)
    ico = tk.StringVar()
    ft = tkFont.Font(family='Times',size=10)
    onefile = tk.Checkbutton(new, font=ft, fg="#333333", text="ONEFILE", offvalue="0", onvalue="1", command=toggle_onefile)
    windowed = tk.Checkbutton(new, font=ft, fg="#333333", text="WINDOWED", offvalue="0", onvalue="1", command=toggle_windowed)
    icon = tk.Entry(new, textvariable=ico)
    onefile.place(x=10,y=10,width=80,height=25)
    windowed.place(x=10,y=40,width=100,height=25)
    new.bind("<Return>", compile)

I expected:

(compile2 function is called) (Python Code Editor is title of root.)

|-Open---[X]
|          |
| Selected |
(Open is clicked)

|-Python Code Editor-------[-[]X]
|  [/]ONEFILE                   |
|  [/]WINDOWED                  |
|_______________________________
(Enter is pressed)

|-Python Code Editor--------------------[X]
| (?) This will install a python package. |
|     Are you sure?                       |
|              Yes / No                   |
|_________________________________________|
(Yes is clicked)

|-Python Code Editor--------------------[X]
| (I) The Python package has downloaded.  |
|                  OK                     |
|_________________________________________|
(OK is clicked)
(Console: )

(pyinstaller compiling)

I got:

(compile2 function is called) (Python Code Editor is title of root.)

|-Open---[X]
|          |
| Selected |
(Open is clicked)

|-Python Code Editor-------[-[]X]
|  [/]ONEFILE                   |
|  [/]WINDOWED                  |
|_______________________________
(Enter is pressed)

|-Python Code Editor--------------------[X]
| (?) This will install a python package. |
|     Are you sure?                       |
|              Yes / No                   |
|_________________________________________|
(Yes is clicked)

|-Python Code Editor--------------------[X]
| (I) The Python package has downloaded.  |
|                  OK                     |
|_________________________________________|
(OK is clicked)
(Console: )

usage: pyinstaller [-h] [-v] [-D] [-F] [--specpath DIR] [-n NAME] [--add-data <SRC;DEST or SRC:DEST>] [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR] [--hidden-import MODULENAME] [--collect-submodules MODULENAME] [--collect-data MODULENAME]
                   [--collect-binaries MODULENAME] [--collect-all MODULENAME] [--copy-metadata PACKAGENAME] [--recursive-copy-metadata PACKAGENAME] [--additional-hooks-dir HOOKSPATH] [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES] [--key KEY]        
                   [--splash IMAGE_FILE] [-d {all,imports,bootloader,noarchive}] [--python-option PYTHON_OPTION] [-s] [--noupx] [--upx-exclude FILE] [-c] [-w] [-i <FILE.ico or FILE.exe,ID or FILE.icns or Image or "NONE">] [--disable-windowed-traceback]
                   [--version-file FILE] [-m <FILE or XML>] [--no-embed-manifest] [-r RESOURCE] [--uac-admin] [--uac-uiaccess] [--win-private-assemblies] [--win-no-prefer-redirects] [--argv-emulation] [--osx-bundle-identifier BUNDLE_IDENTIFIER]
                   [--target-architecture ARCH] [--codesign-identity IDENTITY] [--osx-entitlements-file FILENAME] [--runtime-tmpdir PATH] [--bootloader-ignore-signals] [--distpath DIR] [--workpath WORKPATH] [-y] [--upx-dir UPX_DIR] [-a] [--clean]
                   [--log-level LEVEL]
                   scriptname [scriptname ...]
pyinstaller: error: the following arguments are required: scriptname

Gorzan
  • 69
  • 9
  • Can anyone please answer my question – Gorzan Dec 28 '22 at 09:21
  • 1
    I think you ought to check what you're sending to system() to verify that the arguments are correct. That'd be the first step to debugging your issue. As the error message indicates, you aren't even passing a main script name. – Ben Y Apr 14 '23 at 20:42

0 Answers0