0% found this document useful (0 votes)
44 views9 pages

PyInstaller with Python 3.13 Setup

The document outlines Experiment No. 13, which involves creating an executable file from a Python program using PyInstaller. It details the installation of PyInstaller, the process of copying a Python script, and the steps taken to build the executable file, culminating in a successful output of 'code11.exe'. The executable performs basic arithmetic operations as demonstrated in the output section.

Uploaded by

rafikhot18
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views9 pages

PyInstaller with Python 3.13 Setup

The document outlines Experiment No. 13, which involves creating an executable file from a Python program using PyInstaller. It details the installation of PyInstaller, the process of copying a Python script, and the steps taken to build the executable file, culminating in a successful output of 'code11.exe'. The executable performs basic arithmetic operations as demonstrated in the output section.

Uploaded by

rafikhot18
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Experiment no 13

Building an Executable File*:


Aim: Create a executable file for any program developed in earlier practical.
Requirement: Python Version - 3.13.0

Name: Yash Anant Kathore

Roll No: 50

Div: C

Branch: AI & Data Science

Output:
Microsoft Windows [Version 10.0.19045.5608]

(c) Microsoft Corporation. All rights reserved.

C:\Users\STUDENT>pip install pyinstaller

Defaulting to user installation because normal site-packages is not writeable

Requirement already satisfied: pyinstaller in c:\users\student\appdata\roaming\python\python313\


site-packages (6.12.0)

Requirement already satisfied: setuptools>=42.0.0 in c:\users\student\appdata\roaming\python\


python313\site-packages (from pyinstaller) (76.0.0)

Requirement already satisfied: altgraph in c:\users\student\appdata\roaming\python\python313\site-


packages (from pyinstaller) (0.17.4)

Requirement already satisfied: pyinstaller-hooks-contrib>=2025.1 in c:\users\student\appdata\roaming\


python\python313\site-packages (from pyinstaller) (2025.1)

Requirement already satisfied: packaging>=22.0 in c:\users\student\appdata\roaming\python\


python313\site-packages (from pyinstaller) (24.2)

Requirement already satisfied: pefile!=2024.8.26,>=2022.5.30 in c:\users\student\appdata\roaming\


python\python313\site-packages (from pyinstaller) (2023.2.7)

Requirement already satisfied: pywin32-ctypes>=0.2.1 in c:\users\student\appdata\roaming\python\


python313\site-packages (from pyinstaller) (0.2.3)
C:\Users\STUDENT>cd\

C:\>cd c:\users\student\appdata\roaming\python\python313

c:\Users\STUDENT\AppData\Roaming\Python\Python313>dir

Volume in drive C has no label.

Volume Serial Number is 7C2E-5FD1

Directory of c:\Users\STUDENT\AppData\Roaming\Python\Python313

03/13/2025 09:54 AM <DIR> .

03/13/2025 09:54 AM <DIR> ..

03/27/2025 01:23 PM <DIR> Scripts

04/02/2025 01:23 PM <DIR> site-packages

0 File(s) 0 bytes

4 Dir(s) 97,427,767,296 bytes free

c:\Users\STUDENT\AppData\Roaming\Python\Python313>cd scripts

c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts>dir

Volume in drive C has no label.

Volume Serial Number is 7C2E-5FD1

Directory of c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts
03/27/2025 01:23 PM <DIR> .

03/27/2025 01:23 PM <DIR> ..

12/09/2024 10:19 AM 11,513,971 [Link]

01/20/2025 04:04 PM 256 [Link]

11/26/2024 11:30 AM 456 [Link]

11/26/2024 11:23 AM 767 [Link]

11/26/2024 11:34 AM 806 [Link]

03/27/2025 10:43 AM 1,306 [Link]

03/27/2025 10:46 AM 694 [Link]

03/27/2025 10:46 AM <DIR> build

03/27/2025 10:46 AM <DIR> dist

03/27/2025 09:28 AM 108,391 [Link]

03/27/2025 09:28 AM 108,391 [Link]

03/13/2025 09:57 AM 108,398 [Link]

03/13/2025 09:57 AM 108,398 [Link]

03/13/2025 09:57 AM 108,398 [Link]

03/13/2025 09:54 AM 108,415 pyi-archive_viewer.exe

03/13/2025 09:54 AM 108,410 [Link]

03/13/2025 09:54 AM 108,413 pyi-grab_version.exe

03/13/2025 09:54 AM 108,409 [Link]

03/13/2025 09:54 AM 108,412 pyi-set_version.exe

03/13/2025 09:54 AM 108,426 [Link]

18 File(s) 12,710,717 bytes

4 Dir(s) 97,427,767,296 bytes free


c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts>pip install pyinstaller

Defaulting to user installation because normal site-packages is not writeable

Requirement already satisfied: pyinstaller in c:\users\student\appdata\roaming\python\python313\


site-packages (6.12.0)

Requirement already satisfied: setuptools>=42.0.0 in c:\users\student\appdata\roaming\python\


python313\site-packages (from pyinstaller) (76.0.0)

Requirement already satisfied: altgraph in c:\users\student\appdata\roaming\python\python313\site-


packages (from pyinstaller) (0.17.4)

Requirement already satisfied: pyinstaller-hooks-contrib>=2025.1 in c:\users\student\appdata\roaming\


python\python313\site-packages (from pyinstaller) (2025.1)

Requirement already satisfied: packaging>=22.0 in c:\users\student\appdata\roaming\python\


python313\site-packages (from pyinstaller) (24.2)

Requirement already satisfied: pefile!=2024.8.26,>=2022.5.30 in c:\users\student\appdata\roaming\


python\python313\site-packages (from pyinstaller) (2023.2.7)

Requirement already satisfied: pywin32-ctypes>=0.2.1 in c:\users\student\appdata\roaming\python\


python313\site-packages (from pyinstaller) (0.2.3)

c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts>copy C:\Users\STUDENT\Desktop\
[Link] c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts

1 file(s) copied.

c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts>pyinstaller --onefile [Link]

1514 INFO: PyInstaller: 6.12.0, contrib hooks: 2025.1

1515 INFO: Python: 3.13.0

1559 INFO: Platform: Windows-10-10.0.19045-SP0

1560 INFO: Python environment: C:\Program Files\Python313

1561 INFO: wrote c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts\[Link]

1618 INFO: Module search paths (PYTHONPATH):


['c:\\Users\\STUDENT\\AppData\\Roaming\\Python\\Python313\\Scripts\\[Link]',

'C:\\Program Files\\Python313\\[Link]',

'C:\\Program Files\\Python313\\DLLs',

'C:\\Program Files\\Python313\\Lib',

'C:\\Program Files\\Python313',

'C:\\Users\\STUDENT\\AppData\\Roaming\\Python\\Python313\\site-packages',

'C:\\Program Files\\Python313\\Lib\\site-packages',

'C:\\Users\\STUDENT\\AppData\\Roaming\\Python\\Python313\\site-packages\\setuptools\\_vendor',

'c:\\Users\\STUDENT\\AppData\\Roaming\\Python\\Python313\\Scripts']

2256 INFO: checking Analysis

2256 INFO: Building Analysis because [Link] is non existent

2257 INFO: Running Analysis [Link]

2259 INFO: Target bytecode optimization level: 0

2259 INFO: Initializing module dependency graph...

2274 INFO: Initializing module graph hook caches...

2421 INFO: Analyzing modules for base_library.zip ...

3511 INFO: Processing standard module hook '[Link]' from 'C:\\Users\\STUDENT\\


AppData\\Roaming\\Python\\Python313\\site-packages\\PyInstaller\\hooks'

7354 INFO: Processing standard module hook '[Link]' from 'C:\\Users\\STUDENT\\AppData\\


Roaming\\Python\\Python313\\site-packages\\PyInstaller\\hooks'

9566 INFO: Processing standard module hook '[Link]' from 'C:\\Users\\STUDENT\\AppData\\


Roaming\\Python\\Python313\\site-packages\\PyInstaller\\hooks'

12402 INFO: Caching module dependency graph...

12437 INFO: Looking for Python shared library...

12466 INFO: Using Python shared library: C:\Program Files\Python313\[Link]

12467 INFO: Analyzing c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts\[Link]

12471 INFO: Processing module hooks (post-graph stage)...


12476 INFO: Performing binary vs. data reclassification (1 entries)

12478 INFO: Looking for ctypes DLLs

12483 INFO: Analyzing run-time hooks ...

12484 INFO: Including run-time hook 'pyi_rth_inspect.py' from 'C:\\Users\\STUDENT\\AppData\\


Roaming\\Python\\Python313\\site-packages\\PyInstaller\\hooks\\rthooks'

12526 INFO: Creating base_library.zip...

12573 INFO: Looking for dynamic libraries

12687 INFO: Extra DLL search directories (AddDllDirectory): []

12687 INFO: Extra DLL search directories (PATH): []

13009 INFO: Warnings written to c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts\


build\code11\[Link]

13025 INFO: Graph cross-reference written to c:\Users\STUDENT\AppData\Roaming\Python\


Python313\Scripts\build\code11\[Link]

13142 INFO: checking PYZ

13142 INFO: Building PYZ because [Link] is non existent

13143 INFO: Building PYZ (ZlibArchive) c:\Users\STUDENT\AppData\Roaming\Python\Python313\


Scripts\build\code11\[Link]

13384 INFO: Building PYZ (ZlibArchive) c:\Users\STUDENT\AppData\Roaming\Python\Python313\


Scripts\build\code11\[Link] completed successfully.

13454 INFO: checking PKG

13454 INFO: Building PKG because [Link] is non existent

13455 INFO: Building PKG (CArchive) [Link]

15251 INFO: Building PKG (CArchive) [Link] completed successfully.

15253 INFO: Bootloader C:\Users\STUDENT\AppData\Roaming\Python\Python313\site-packages\


PyInstaller\bootloader\Windows-64bit-intel\[Link]

15253 INFO: checking EXE

15254 INFO: Building EXE because [Link] is non existent

15254 INFO: Building EXE from [Link]


15255 INFO: Copying bootloader EXE to c:\Users\STUDENT\AppData\Roaming\Python\Python313\
Scripts\dist\[Link]

15904 INFO: Copying icon to EXE

16162 INFO: Copying 0 resources to EXE

16163 INFO: Embedding manifest in EXE

16721 INFO: Appending PKG archive to EXE

16826 INFO: Fixing EXE headers

18716 INFO: Building EXE from [Link] completed successfully.

18718 INFO: Build complete! The results are available in: c:\Users\STUDENT\AppData\Roaming\Python\
Python313\Scripts\dist

c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts>cd dist

c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts\dist>dir

Volume in drive C has no label.

Volume Serial Number is 7C2E-5FD1

Directory of c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts\dist

04/08/2025 12:56 PM <DIR> .

04/08/2025 12:56 PM <DIR> ..

03/27/2025 10:46 AM 7,202,661 [Link]

04/08/2025 12:56 PM 7,201,824 [Link]

2 File(s) 14,404,485 bytes

2 Dir(s) 97,408,278,528 bytes free

c:\Users\STUDENT\AppData\Roaming\Python\Python313\Scripts\dist>[Link]
Name of student: Yash Anant Kathore

Roll no: 50

Batch: C3

Branch: AI & Data Science

Current date and time is 2025-04-08 12:57:45.861152

**********************************************************************

Please select operation-

[Link]

[Link]

[Link]

[Link]

Select opertions from 1,2,3,4:1

Enter first number:3

Enter seond number:2

3+2=5

Select opertions from 1,2,3,4:2

Enter first number:4

Enter seond number:2

4-2=2

Select opertions from 1,2,3,4:3

Enter first number:5

Enter seond number:2

5 * 2 = 10

Select opertions from 1,2,3,4:4


Enter first number:5

Enter seond number:2

5 / 2 = 2.5

Select opertions from 1,2,3,4:

Common questions

Powered by AI

Creating executables with PyInstaller can pose challenges such as missing modules or incompatible library versions. These can result from incorrect paths or unresolved dependencies automatically detected by PyInstaller. To address these issues, pre-installation of all dependent packages is crucial, ensuring compatibility across packages using PyInstaller's hook system. Modules often need explicit inclusion in the spec file, which informs PyInstaller about their presence. Build warnings and errors are documented in log files, which provide insights into missing components or incorrect configurations, leading to informed troubleshooting .

PyInstaller determines the paths for modules and packages by examining the Python environment's settings, including 'PYTHONPATH', as well as scanning directories such as those from installed site-packages in the Python environment. It uses the module search paths defined during its execution, which include paths from the PyInstaller executable location, compressed Python libraries, and site-packages directories to gather all necessary dependencies and module hooks for creating the executable .

PyInstaller manages platform-specific dependencies by integrating system-specific shared libraries and dynamically linked modules into the executable package. On Windows, it identifies necessary DLLs and libraries via its hooks and includes them within the standalone executable, thus preventing dependency issues across different Windows environments. The bootloader, also specified per platform, supports managing and recognizing these system-level dependencies, executing them seamlessly with the Python interpreter bundled in the executable, ensuring cross-stability and functionality irrespective of the user's system configuration .

To create an executable file using PyInstaller, the user needs to have Python version 3.13.0 and PyInstaller already installed in their Python environment. PyInstaller requires certain packages such as 'setuptools', 'altgraph', 'pyinstaller-hooks-contrib', 'packaging', 'pefile', and 'pywin32-ctypes' to be installed . The installation command 'pip install pyinstaller' is used, and it is stipulated that these packages should not conflict with each other, especially 'pefile' which has specific version requirements .

During compilation, PyInstaller generates several files and directories. Key outputs include the '.spec' file, which records configuration and options used for building the executable, the 'build' directory containing intermediate files like 'Analysis-00.toc' and 'warn-code11.txt', and the 'dist' directory, which contains the final executable file (e.g., 'code11.exe'). The 'base_library.zip', 'PYZ', and other support files like any required dynamic link libraries (DLLs) are also part of the process, all generated with the aim of packing all dependencies into a single executable package .

PyInstaller manages dynamic linking by looking for shared libraries required at runtime and includes them within the built executable. It adds search directories for DLLs and dynamically linked libraries that are essential for the execution of the final standalone application . Furthermore, it uses hooks to identify and include these dependencies so that the executable does not require external libraries present on the execution platform .

The '.spec' file is crucial as it defines the build configuration for PyInstaller and contains specifications such as dependencies, custom paths, entry points, and additional files to be included. Developers can modify the '.spec' file to customize the build process, such as specifying hidden imports or additional data files that PyInstaller failed to detect automatically. It also allows the inclusion of specific hooks, setting options for the compression level of the package, and configurations required for specific environments. Altering this file affects how the executable is packaged and the resources it includes .

The PyInstaller build process involves multiple steps. Initially, it checks and initiates 'Analysis', which includes creating a dependency graph and processing module hooks . This is followed by building the 'base_library.zip' and locating shared libraries. It analyzes the Python script to include all the necessary dependencies. Next, the 'PYZ' (Python Archive) file is built and compressed. The 'PKG' (CArchive) archive is constructed next, which is embedded into the bootloader. Finally, the executable (EXE) file is created by combining the bootloader, the PKG archive, and any additional resources that are needed .

The PyInstaller bootloader, crafted from a small C program, is the first code executed when the application runs. It initializes the execution environment and sets up the necessary paths before unpacking and executing the bundled Python bytecode. The bootloader decompresses 'base_library.zip', loads the Python interpreter, and dynamically links included DLLs within the self-contained executable, creating an isolated environment. The bootloader's configuration is embedded in the executable, making the app distribution straightforward without needing a Python installation on the user's system .

PyInstaller ensures portability by packaging Python applications along with all necessary libraries, dependencies, and a Python interpreter into a single executable file. This includes all Python modules and any dynamic libraries used by the script. The embedded bootloader initializes these components without relying on system-wide Python installations. PyInstaller's configuration file consolidates all dependencies and paths, reducing external dependencies by encapsulating everything into the executable. This self-contained nature allows the executable to be run on any compatible Windows system without specific setup needs .

You might also like