An easy way to convert your python file to exe file. To decrease the size of your exe file, you can select your own python environment for the conversion.
Download the Python_to_EXE.exe to convert your python file. This converter can convert python file (“.py file”) to exe file
The general sequence of the operation step is the serial number shown in the GUI. Before using the converter,
Note:
- Please ensure that the Anaconda is installed in the computer. If there is no anaconda in the computer, please download it from “https://www.anaconda.com/”.
- Please install a python IDE to run the python file such as Visual studio code or PyCharm. In this manual, the explanation will base on Visual studio code.
If the python file runs in the default Anaconda python environment which may include too much useless python package of a certain python program, the file size of exe converting output will become very big and it will cost too much time to convert. To solve this problem, users can set a new environment that only contains necessary python package of a certain python program. User can click the choice box of “New Environment” to create a new python environment. To set a new environment, user must input the new environment name and python version. The python version of the computer can be found by following steps.
- Press button “Windows” + “R”
- Type in “cmd” and press “Enter”
- Type “python” in the prompt and press “Enter”
- The text in the red box is the python version
The name of the new environment should be different with the exist environment name. The exist name of environment can be found by the following step:
- Press button “Windows” + “R”
- Type in “cmd” and press “Enter”
- Type “conda info -e” in the prompt and press “Enter”
- The text in the red box is the exist environment name
If the user doesn’t want to create a new python environment, user can use the exist python environment. After setting the new python environment, please click the “set new python environment” button.
After setting the new environment, users should install necessary python package for the new python environment. In this step, users should input the list of pip packages used in the python program file. The step to install the pip package in the new python environment follows:
- Open the python file that needs to be convert by IDE
- Click the red box shown in the following figure.
- Choose the new environment that is set in the previous step in the pop-up window.
- Check which package is labeled in yellow line in the python program “import” section. In the example (following figure), the python package should be installed is “requests”, “pyqt5” and “download”.
- Type the package name in the memo (shown in the figure).
Note: a. If the check box of “Auto pip command” is selected, it means that user can just input the name of package and the converter will use the pip command: “pip install [package name]” automatically. b. If user doesn’t click this check box, users have to input the full pip installation command in the memo by themselves. c. The check box of “install pyinstaller” is the switch of installing the package called pyinstaller which can convert python file to exe file. Normally, this check box should always be selected for the converting process.
Please follow the instructions shown in the GUI.
After finishing all the settings, please click the “packaging” button to convert the selected python file to exe file. After waiting for the converting process, if the prompt window shows “successfully” (in the figure), it means the process is success. If the prompt doesn’t show the text of “successfully”, please try to run the python file in the new python environment to check whether some python package is not installed successfully.
The output file path is in the “dist” folder of the python file directory. Users can click the “Open output folder” button to open the output folder to find the exe file.