Auto Py To Exe
This project allows you to convert python scripts to executables with a simple interface. The interface uses chromes app mode and lists all possible flags for pyinstaller. The whole idea seems automatic as it cleans up after itself.
This application displays a simple interface that allows you to convert py to exe easily. By just selecting the file, if you want it to convert to onefile and if you want a console, you will only need to press convert and wait for the script to do the rest.
The script is built using Eel and uses PyInstaller to convert the script
- Python : 3.6-3.10
To have the interface displayed in the images, you will need chrome. If chrome is not installed or —no-chrome is supplied, the default browser will be used.
Installation and Usage
You can install this project using PyPI:
Then to run it, execute the following in the terminal:
Then to run it, execute the following in the terminal:
Running Locally Via Github (no install)
You can run this project locally by following these steps: 1. Clone/download the repo 2. Open cmd/terminal and cd into the project 3. Execute python -m pip install -r requirements.txt
Now to run the application, execute python -m auto_py_to_exe . A Chrome window in app mode will open with the project running inside.
Make sure you are in the directory below auto_py_to_exe (you will be after step 3) when calling python -m auto_py_to_exe or you will need to reference the folder auto_py_to_exe absolutely/relatively to where you currently are.
Using the Application
- Select your script location (paste in or use a file explorer)
- Outline will become blue when file exists
- Select other options and add things like an icon or other files
- Click the big blue button at the bottom to convert
- Find your converted files in /output when completed
Usage: auto-py-to-exe [-nc] [-c [CONFIG]] [filename]
Argument | Type | Description |
---|---|---|
filename | positional | Pre-fill the «Script Location» field in the UI. |
-nc, —no-chrome | optional | Open the UI using the default browser (which may be Chrome). Will not try to find Chrome |
-c [CONFIG], —config [CONFIG] | optional | Provide a configuration file (json) to pre-fill the UI. These can be generated in the settings tab. |
-o [PATH], —output-dir [PATH] | optional | Set the default output directory. This can still be changed in the ui. |
If you are running this package locally, you will need to call python -m auto_py_to_exe instead of auto-py-to-exe
Instead of inserting the same data into the UI over and over again, you can export the current state by going to the «Configuration» section within the settings tab and exporting the config to a JSON file. This can then be imported into the UI again to re-populate all fields.
This JSON config export action does not save the output directory automatically as moving hosts could mean different directory structures. If you want to have the output directory in the JSON config, add the directory under nonPyinstallerOptions.outputDirectory in the JSON file (will need to create a new key).
If you need something visual to help you get started, I made a video for the original release of this project; some things may be different but the same concepts still apply.
Issues Using the Tool
If you’re having issues with the packaged executable or using this tool in general, I recommend you read my blog post on common issues when using auto-py-to-exe. This post covers things you should know about packaging Python scripts and fixes for things that commonly go wrong.
I really wanted to get this project out there so I released a YouTube video demonstrating how to set up and use the interface (video above). A day later I made a post in the /r/Python subreddit titled «Auto Py to Exe is Complete». To my surprise, the next morning (about 7 hours) I had more than 300 upvotes which to me was a big thing. I had many replies which I took time to read and reply to. About 44 hours later the post finally lost its top place on the subreddit and the post is sitting at 454 points with 12.1k views and 75 comments. I can’t believe how big this got and it means a lot to me when I saw people thanking me for the project. When a couple of issues came to the Github repo I realised people do care about this and I was quick to fix these. Once again, thank you for the support; I loved making this project.
Owner of PyTutorials and creator of auto-py-to-exe. I enjoy making quick tutorials for people new to particular topics in Python and tools that help fix small things.
Преобразуем проект на Python в исполняемый файл .EXE
С помощью Auto PY to EXE можно с лёгкостью преобразовывать файлы .py в файлы .exe . Благодаря этому ваш проект на Python будет работать как десктопное приложение и вы сможете запускать приложение на других машинах без необходимости установки Python.
В этой статье я расскажу, как преобразовать проект на Python в исполняемый файл. Решение будет работать вне зависимости от количества файлов .py в приложении. Стоит учесть, что Auto PY to EXE работает только с Python 3.5 или выше.
Установка Auto PY to EXE
Установка через pip
При помощи следующей команды можно установить текущую версию Auto PY to EXE.
Установка с GitHub
Также можно выполнить установку напрямую с GitHub. Для установки Auto PY to EXE с GitHub необходимо сначала клонировать репозиторий GitHub.
Затем нужно перейти в папку auto-py-to-exe .
Теперь необходимо запустить файл setup.py .
Можно также проверить версию при помощи следующей команды:
Проверяем версию
Текущая версия Auto PY to EXE 2.9.0 и теперь она установлена на ваш компьютер.
Открываем приложение
Чтобы открыть Auto PY to EXE, нужно выполнить в терминале следующую команду:
Откроется удобное приложение с GUI:
Интерфейс пользователя Auto PY to EXE
Теперь с помощью этого интерфейса можно преобразовать файл .py в .exe .
Процесс преобразования
Шаг 1. Добавляем местоположение файла
Для преобразования .py в .exe сначала необходимо указать путь к файлу Python. Достаточно перейти к местоположению файла, который нужно преобразовать, а затем добавить путь.
Добавляем местоположение файла
Я добавил местоположение основного файла Python моего проекта. Здесь я использую для примера один из своих проектов на Python. Это приложение с GUI, визуализирующее различные алгоритмы сортировки. О создании этого проекта можно прочитать здесь: Build a Sorting Algorithm Visualizer in Python
Шаг 2. Выбор «One Directory» или «One File»
В интерфейсе есть опция выбора «One Directory» или «One File». Мой проект на Python содержит несколько других файлов, поэтому я выбрал «One Directory». Эта опция создаст папку со всеми необходимыми файлами, а также с файлом .exe .
One directory или One file
Шаг 3. Выбор «Console Based» или «Window Based»
После этого нужно будет выбрать тип приложения: консольное (Console Based) или оконное (Window Based). Если выбрать «Window Based», то это скроет весь консольный вывод приложения. Если ваш проект генерирует консольный вывод, то нужно выбрать «Console Based». Если у вас приложение с GUI или вам не нужно отображать пользователю консольный вывод, то выберите «Window Based». Я выбрал второй вариант, потому что моё приложение имеет GUI.
Console Based или Window Based
Шаг 4. Преобразование
Далее отобразятся другие опции, такие как добавление значков, дополнительных файлов и т.д. Выберите нужные опции самостоятельно. Ну а наш файл .py уже к преобразованию. Достаточно нажать на кнопку CONVERT .PY TO .EXE .
Нажмите кнопку для преобразования
Для завершения процесса придётся немного подождать.
Папка с результатами
После завершения процесса можно будет выбрать опцию открытия папки с результатами.
По умолчанию папка с результатами будет создана там, откуда вы запускали Auto PY to EXE. Я открывал Auto PY to EXE с рабочего стола, поэтому папка создана на нём. В папке находится множество файлов и папок. Но нам важен файл с расширением .exe . В моём случае это main.exe . При двойном нажатии будет запускаться программа.
Готово! Наш проект на Python теперь преобразован в исполняемый файл. Его можно запускать на других компьютерах без необходимости установки Python.
Ресурсы
На правах рекламы
Серверы для всех, в том числе, и для разработчиков! VDS с посуточной оплатой на базе новейших процессоров AMD EPYC и хранилища на основе NVMe дисков от Intel для размещения проектов любой сложности, создавайте собственную конфигурацию сервера в пару кликов!
Auto PY to EXE
The only tool that we are gonna be using is Auto PY to EXE!
Auto PY to EXE is an amazing application for making .exe files out of your project whether it is one .py file or any number of them.
The application has a nice GUI and looks like this:
How to start
Step 1. Installation
Installing using PyPI:
To install the application run this line in cmd:
pip install auto-py-to-exe
To open the application run this line in cmd:
Note: if you have problem installing this way or you want to install it from GitHub go to the main page or watch this instructional video by the developer of “Auto PY to EXE” himself.
For more additional information use this
“Issues When Using auto-py-to-exe”
Step 2. Converting
There are few main options you need to choose:
- Pick your .py file
- Pick “One Directory” or “One File” option
- Pick additional files
1. Pick your .py file
If you have multiple files choose one that starts the program.
2.1. “One Directory” option
Pretty simple. When choosing “One Directory” option “Auto PY to EXE” will put all dependencies in one folder. You can choose Output directory in “Advanced” menu. If you have media files like icons and backgrounds you should’t have any problems using them inside your .exe if you place media files/folders in Output directory.
Something like this:
2.2. “One File” option
When choosing “One File” option “Auto PY to EXE” will create one .exe file containing all dependencies but NOT MEDIA FILES. If your program has only default Windows gui with no icons, backgrounds, media files or you are OK with placing media folder with .exe file feel free to skip the following explanation. For those who want to pack media files into .exe file itself read paragraph 3.
3. Pick additional files
There is a menu in “Auto PY to EXE” called “Additional Files” that lets you add files of your choice. There is a catch though. “Auto PY to EXE” uses pyinstaller which unpacks the data into a temporary folder, and stores this directory path in the _MEIPASS environment variable. Your project won’t find necessary files because the path changed and it won’t see the new path eather. In other words, if option “One File” is choosen picked files in the “Additional Files” menu will not be added to .exe file. To work around this you should use this code provided by developer of Auto PY to EXE here
To use this code in your project replace the link to the media file you have now
For example:
Now the link will be referenced correctly and chosen files successfully packed into .exe file.
For comparison:
Possible link before
Possible link after
Press CONVERT .PY TO .EXE
Step 3. Run your program!
Now everything is done!
Run it. Test it. See what`s up.
Make sure everything works well.
You made One Directory
Every file you need should be in a single directory.
You made One File
This way you should have single .exe file. If you had a need and if done correctly your .exe file will be packed with all media inside it. You will not need any media files/folders present with .exe file for it to display them properly.
If you have any feedback or suggestions on what important information should be added feel free to let me know!
This guide is not a description of every possible option done every possible way.
I hope you found that information useful!
Good luck with your projects!
Auto py to exe Tutorial
report this ad
report this ad
report this ad
This tutorial covers the Python library Auto py to exe.
Introduction
When you normally write Python code you end up using many different libraries that you specially download and install. And most importantly, you need the actual Python interpreter to even be executing Python code in the first place.
The problem is that while you have all these libraries and Python installed on your PC, the person who you may want to share your program with, will likely not even have Python, much less any of it’s libraries. We call things like these dependencies, because we depend on them for our program to run successfully.
Auto py to exe is a special Python library that can convert a Python .py file to an executable with all dependencies packed. Another benefit is that the executable file produced by Auto py to exe is a compiled version of the source code, not the actual source code. This helps prevent people from stealing from your code.
In this Auto py to exe tutorial we’ll be explaining everything, from it’s installation to actually using it.
Prerequisites
Before you begin using auto-py-to-exe, you’ll need 2 two things installed in your PC. You’ll obviously need Python to execute the auto-py-to-exe code, and you’ll also require the Chrome web browser to be installed.
The reason for having the Chrome web browser is that the interface that Auto-py-to-exe creates is on Chrome. You’ll basically be interacting with Auto-py-to-exe through a chrome browser window.
Auto-Py-to-Exe Installation
There are two different methods through which we may avail Auto-Py-to-Exe’s features.
Method 1
This method involves using the pip to install the library using the pip install auto-py-to-exe command in the command prompt. You can use other package installers besides pip as well. Don’t forget to include the dashes.
Next you just have to type in auto-py-to-exe into the command prompt. This will automatically open up the interface for Auto-py-to-exe.
For this to work, you might have to have the file path of the Python exe added to Path. If you haven’t done this step already, you can learn how to do so from this Python installation guide. Otherwise you can try navigating to the Python installation yourself using the command prompt.
Method 2
If you’re having trouble with the 1st method, you can use this one as an alternate. In this method we won’t actually be installing Auto py to exe using pip or some other means. Instead, we’ll be directly downloading the source code for the library and running it manually.
First visit the GitHub page for this library and download the code using the download ZIP option as shown in the image below.
Next extract the file, locate the python file called run.py and execute it (by clicking on it). This should open up the GUI interface for auto-py-to-exe (pictured below)
Auto-Py-to-Exe Settings
Once you’ve completed any of the above two methods, the following interface should open up. This is the Auto Py to Exe window through which we’ll be converting our files. We also have access to several settings like OneFile and Console Window.
Script Location
The Script Location setting takes a simple file path of the .py which is to be converted. You can directly type in the file path or use the browse option to manually find the file on your computer.
OneFile
By default the setting on Auto-py-to-Exe is set to one-dir . This compiles all the related files and dependencies into many files located within a single directory.
Enabling the one-file instead will combine the files into a single bigger executable. If you’re experiencing an issue with either setting, try switching to the other.
Console Window
By default Auto-Py-to-Exe will open up a console window when the executable file is run. If your program is console based, you’ll need this console window to interact with the program.
If however your program is GUI based, you should switch to Window based. This will stop the console window from appearing. There’s not much point in having a console window when you have your own GUI to interact with.
Additional Files
Often when you’re making proper software, especially one’s with GUI’s you’ll end up using additional files like images, text files etc. Now obviously, you want them automatically bundled into the file produced by Auto-Py-to-Exe. Just add them using the add files or add folder setting and you’ll be good to go.
The default icon that appears on the Python executable file isn’t exactly very pretty. If you want your program to look more professional and better you can create your own custom Icon and link it’s file path to Auto-Py-to-Exe.
Output Directory
Located in settings, this option allows you the set a custom location for where the executable file is generated.
Once you’re done picking all the settings you want, just hit the “Convert” button. The process of converting the Python file will take about 5 – 10 mins. There will be several warnings and error messages in the output log, but don’t worry about those too much. It’s fairly normal.
Hope you enjoyed this Auto py to Exe Tutorial!
Alternatives to Auto-py-to-EXE
There are others options other than just Auto Py to Exe. You can also use Pyinstaller which is another pretty reliable library for creating Exe’s. And in-fact, Auto-py-to-Exe uses pyinstaller under the hood. Auto-py-to-Exe does not provide any new functionality. It just provides the GUI interface and makes things easier for the end-user.
-
: A rather unique take on python deployment, which first converts Python to C code, then compiles it into Machine code. This produces an executable which can be shared, and also improves performance of your code substantially.
: Another good library which has its faults, but also has certain pro’s over Auto-py-to-EXE / Pyinstaller. You can read about it’s pro’s and con’s here.
This marks the end of the Auto py to exe tutorial. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the article content can be asked in the comments section below.