Is there a way to make an executable file that runs a python file in which a different python file is executed?

PythonSnek

I have a big python project which I'm currently developing, and I want to make a .exe file that launches the main.py file. I have a file called ultimate_launcher.py which has the following code:

exec(open("main.py").read())

That is a solution I found somewhere on Stack Overflow. it runs fine as a .py file, but when I use pyinstaller to convert it to a .exe, it has a "Fatal" error,

Failed to execute script ultimate_launcher

I don't want the rest of my project to be put into the .exe as I am still in the process of development. So my question is how do I make a .exe that ONLY references the file main.py so when it gets updated, i don't have to remake the .exe file.

py

Michael Royston

I believe there is a method to achieve this detailed in this thread:

Python - create an EXE that runs code as written, not as it was when compiled

EDIT: This works

import subprocess
f = open("c:\\temp\\temp.py", "w")
f.write(open("main.py").read())
f.close()
subprocess.call("\"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python37_64\\Scripts\\pyinstaller.exe\" --distpath \"c:\\temp\" c:\\temp\\temp.py " )
subprocess.call("C:\\temp\\temp\\temp.exe")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Convert python script which runs a bash script to executable file with Pyinstaller

how to make a windows python file executable in android

Python how to make an executable from a text file

PHP page runs Batch file which runs an executable file that should show GUI but it does not

Which File Is The Executable

Creating Executable File For Python 2.7

Trying to convert python file to executable

Python Executable File closes instantly

Using pyinstaller to make an executable file from python .py file utilizing Pandas to read a CSV file?

How to make executable Python file from .ipynb (Jupyter Notebook)?

How do I make a python file executable on macOS Sierra?

How to make pefile python module read multiple executable file in a directory

"‘python’: No such file or directory" when running Python file as executable

which file is executed first in pytest?

php file executed even without executable permissions

File executable by all, yet still cannot be executed?

is ther any more efficient way to make python file by python?

Run an executable after moving it to a different directory in the make file

Best way to make a node.js file executable using nvm

Which file is binary file type - Python?

Python - Import module which has a different name to file?

Python scripts in different directories use the same file in which import breaks

Python/socket: How to send a file to another computer which is on a different network?

Which is a good way to open a 'complicated' txt file in python

Can I make an app which has a python program file in it?

Creating executable file of my python script

How to get path to file for python executable

error in creating executable file from python

"exec: "python": executable file not found in $PATH

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive