If you choose “Console Based,” the console will open after running the executable file, which is recommended if your script generates console-based outputs. Now it’s time to choose whether the console will be displayed or not. Choosing “Console Based” or “Window Based” Now we have to choose whether we want to create “one directory” or “one file.” The first creates a directory with all the dependencies your script needs to run (including the executable file), while the second creates only a single executable file.įor this example, I’ll choose the “one file” option. application_path = os.path.dirname(sys.executable) Step 2: Choosing “One Directory” or “One File” If necessary, include the following line of code below to know where the executable file is located and make the necessary changes to your script so you read/export files on the right directory. However, if your script needs to read a path make sure that you use absolute paths since relative paths won’t behave as you might expect with executable files. exe, in case you prefer watching the steps below rather than reading them.įeel free to choose any script you want. The first option offers a nice GUI (graphical user interface) that takes care of all the stuff necessary to convert your Python script into an executable file.īy the way, you can also watch my YouTube video to learn how to convert a. Making an Executable file with PyInstaller Making an Executable file with auto-py-to-exe output directory, additional import) - Step 5: Convert the file 2. Choosing “Console Based” or “Window Based” - Step 4: Advanced option(e.g. Making an Executable file with auto-py-to-exe - Installing with pip - Running auto-py-to-exe - Step 1: Add the script location - Step 2: Choosing “One Directory” or “One File” - Step 3. The first (auto-py-to-exe) has a friendly interface that will help beginners to easily create executables, while the second (PyInstaller) offers a straightforward way to create executables through the terminal. Whatever the situation, in this guide, I will show you 2 ways to create an executable file. Maybe you need to send the script to someone who doesn’t code at all or you might need to schedule a job that runs a. Although running a Python script using the terminal or your favorite text editor is straightforward, there are some situations in which you will prefer to hide all the code written in the script (.py) inside an executable file (.exe).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |