Auto py to exe как запустить
Перейти к содержимому

Auto py to exe как запустить

  • автор:

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.

Empty interface

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

  1. Select your script location (paste in or use a file explorer)
    • Outline will become blue when file exists
  2. Select other options and add things like an icon or other files
  3. Click the big blue button at the bottom to convert
  4. 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.

Empty interface

Filled out

Converting

Completed

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.

Name already in use

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

A .py to .exe converter using a simple graphical interface and PyInstaller in Python.

Empty interface

Suomenkieliset käyttöohjeet löydät täältä

  • Python : 3.6-3.11

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.

As of PyInstaller 4.0, Python 2.7 is no longer supported. Read «Python 2.7 Support» below for steps on how to use this tool with Python 2.7.

Installation and Usage

You can install this project using PyPI:

Then to run it, execute the following in the terminal:

If you have more than one version of Python installed, you can use python -m auto_py_to_exe instead of auto-py-to-exe .

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

  1. Select your script location (paste in or use a file explorer)
    • Outline will become blue when file exists
  2. Select other options and add things like an icon or other files
  3. Click the big blue button at the bottom to convert
  4. Find your converted files in /output when completed

Usage: auto-py-to-exe [-nc] [-c [CONFIG]] [-o [PATH]] [filename]

Argument Type Description
filename positional/optional 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.
-nu, —no-ui optional Don’t try to open the UI in a browser and simply print out the address that the application can be accessed at.
-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.
-bdo [FOLDER_PATH], —build-directory-override [FOLDER_PATH] optional Override the default build directory. Useful if you need to whitelist a folder to stop your antivirus from removing files.
-lang [LANGUAGE_CODE], —language [LANGUAGE_CODE] optional Hint the UI what language it should default to when opening. Language codes can be found in the table under «Translations» below.

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.

If you believe you’ve found an issue with this tool, please create an issue (click «Get started») and fill out the template provided by the «Bug report» option. If your issue is only associated with your application, please do not create an issue in this repository — instead, comment on the help post, video or create a new discussion.

When filling out the template, be sure to clearly explain what’s happening, give reproduction steps and a minimal reproducible example and explain what you believe should have happened. Without these, it’s going to take longer to identify the issue.

Language Code Translator Translated
Arabic (العربية) ar Tayeb-Ali UI
Brazilian Portuguese (Português Brasileiro) pt_br marleyas UI (partial)
Chinese Simplified (简体中文) zh jiangzhe11 UI and README
Chinese Traditional (繁體中文) zh_tw startgo UI
Czech cz Matto58 UI
English en UI and README
Finnish (Suomen kieli) fi ZapX5 UI and README
French (Français) fr flaviedesp UI
German (Deutsch) de hebens, ackhh UI
Greek (Ελληνικά) gr sofronas UI
Indonesian (Bahasa Indonesia) id MarvinZhong UI
Italian (Italiano) it itsEmax64 UI
Japanese (日本語) ja NattyanTV UI
Russian (Русский) ru Oleg UI
Spanish (Español) sp enriiquee UI
Spanish Latam (Español Latam) sp_la Matyrela UI
Serbian sr rina UI
Thai (ภาษาไทย) th teerut26 UI (partial)
Turkish (Türkçe) tr mcagriaksoy UI
Ukrainian (Українська) ua AndrejGorodnij UI

Want to add a translation for another language? Update i18n.js and submit a PR or attach it in an issue.

Python 2.7 Support

As of PyInstaller v4.0 released on Aug 9 2020, Python 2.7 is no longer supported; although you can still use this tool with Python 2.7 by installing an older version of PyInstaller. PyInstaller v3.6 was the last version that supported Python 2.7; to install this, first uninstall any existing versions of PyInstaller and then execute python -m pip install pyinstaller==3.6 .

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:

  1. Pick your .py file
  2. Pick “One Directory” or “One File” option
  3. 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: Only One File – WITH IMAGES – For Our Python Apps

If you wonder how to make an .exe file to distribute your python app, just read this post and you’ll see how to do it with auto-py-to exe.

Brent Vollebregt is the author of this great app.

Pyinstaller

First you need to install pyinstaller, as the program is based on this module.

pip install pyinstaller

Auto-py-to-exe

Now you can install auto-py-to-exe.

pip install auto-py-to-exe

Run auto-py-to-exe

Now you can run it like so:

I cannot include images in the exe

One problem could be this: you have to put the images into the folder of the exe file. But why you cannot include the images into the exe file instead, so that i have one only file to distribute with my app?

Here is the solution.

Once you set the Auto-py-to-exe like this, if you have an like like the following

Remember to put an image called “image2.png” in the folder of this script to make it work. If resource_path0 does not work, try resorce_path or resource_path2.

Another example of use of the functions resource_path0 in another game

If you liked this post, come here more often to find other interesting curiosity about python.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *