[Python] Pyinstaller config

Discussão em 'Python' iniciado por Stack, Julho 17, 2025.

  1. Stack

    Stack Membro Participativo

    Here i developed the project that would execute the python script and get the terminal output and generate as the pdf , thus when i used to convert my project in the exe format first the subprocess has opening the new window , then i rectified by

    python_exe = Path(sys.executable).with_stem("python")

    result = subprocess.run(
    [str(python_exe), script_path],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    text=True,
    timeout=10,
    creationflags=subprocess.CREATE_NO_WINDOW
    )


    then, when i generated the exe file it shows the error of specified file has not found

    here is my code

    def execute_script_to_pdf(self, script_path, output_pdf_name):
    try:
    print(script_path)
    python_exe = Path(sys.executable).with_stem("python")

    result = subprocess.run(
    [str(python_exe), script_path],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    text=True,
    timeout=10,
    creationflags=subprocess.CREATE_NO_WINDOW
    )

    output_text = result.stdout + "\n" + result.stderr

    # Save output_text as PDF in the 'pdfs/' folder
    folder = "pdfs"
    os.makedirs(folder, exist_ok=True)
    pdf_path = os.path.join(folder, output_pdf_name)

    self.pdf_canvas.create_pdf(output_text.strip(), pdf_path)
    print(f"✅ PDF created: {pdf_path}")
    return pdf_path

    except Exception as e:
    QMessageBox.critical(self, "Execution Error", f"Script execution failed:\n{e}")
    return None


    thus when i used to convert my project in the exe format first the subprocess has opening the new window , then i rectified by

    python_exe = Path(sys.executable).with_stem("python")

    result = subprocess.run(
    [str(python_exe), script_path],
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    text=True,
    timeout=10,
    creationflags=subprocess.CREATE_NO_WINDOW
    )


    then, when i generated the exe file it shows the error of specified file has not found

    Continue reading...

Compartilhe esta Página