==============================================
Step 1: Install the Pyinstaller Package
pip install pyinstaller
Step 2: Locate your Python Script
C:\GlobalSino\images\Testing.py
![C:\GlobalSino\images\Testing.py](images/4688b.PNG)
Step 3: Locate the folder of the Python script by "cd":
Go to the Command Prompt, and then type:
cd followed by the location where your Python script is
cd C:\GlobalSino\images:
![C:\GlobalSino\images](images/4688a.PNG)
Step 4: Create the Executable using Pyinstaller
pyinstaller --onefile Testing.py
A folder named "dist" has been created:
![C:\GlobalSino\images\Testing.py](images/4688c.PNG)
In this folder, the excutable file has been created:
![C:\GlobalSino\images\Testing.py](images/4688d.PNG)
Step 5: You can double-click the file Testing.exe to verify the output by pasting the content "Yougui Liao!" into notpad:
![C:\GlobalSino\images\Testing.py](images/4688e.PNG)
Step 6: Additional function: Add an icon:
pyinstaller -w -F - i python.ico Testing.py
pyinstaller -i C:\GlobalSino\images\python.ico Testing.py
==============================================
Step 1: Locate your Python Script
C:\GlobalSino\images\Testing.py
![C:\GlobalSino\images\Testing.py](images/4688b.PNG)
Step 2: Run Pyinstaller command
pyinstaller --onefile -w Testing.py
Step 3: build and distribution directories are created in Step 2.
![C:\GlobalSino\images\Testing.py](images/4688f.PNG)
Step 4: Go inside dist directory and you will find .exe file:
![C:\GlobalSino\images\Testing.py](images/4688g.PNG)
Step 5: Double click the .exe file:
![C:\GlobalSino\images\Testing.py](images/4688g.PNG)
Step 6: Paste to get the contents from the clipboard:
Yougui Liao!
==============================================
Step 1: Install the support library:
pip install auto-py-to-exe
Step 2: run this line in cmd:
Step 3. An User Interface (UI) will open:
![C:\GlobalSino\images\Testing.py](images/4688i.PNG)
Step 4. Pick your .py file
If you have multiple files, then choose one that starts the program:
![C:\GlobalSino\images\Testing.py](images/4688j.PNG)
4.1. "One Directory" option:
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 there are 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.
4.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 it is OK with placing media folder with .exe file feel free to skip the following explanation.
4.3. Pick additional files:
There is a menu in "Auto PY to EXE" called "Additional Files" that lets you add files of your choice.
Step 5. Press CONVERT .PY TO .EXE
Step 6. Locate the .exe file:
Step 7. The .exe file is at:
![C:\GlobalSino\images\Testing.py](images/4688l.PNG)
Step 8. Double click the .exe file and then paste the contents in notepad:
==============================================
Step 1: Install the support library:
pip install Py2exe
Step 2: Create a new file setup.py at the same directory where you have the script. This setup.py file contains:
Step 3. Launch the command prompt and type the command below to convert the python script to exe. You must run the command from the same directory where the setup.py file is:
python setup.py py2exe
Note: This method often has some error, like "ModuleNotFoundError: No module named 'Py2exe'" or "AttributeError: module 'py2exe' has no attribute 'build_exe'".
|