{"flag":true,"single":true,"pageTitle":"PYthon code to exe","post":{"id":297,"user_id":"1","slug":"python-code-to-exe-n08l","title":"PYthon code to exe","body":"<p>Converting a Python script into an installer allows you to distribute your program as a standalone executable file that can run on computers without requiring Python to be installed. One of the most popular tools for this is PyInstaller, which bundles your Python code, dependencies, and the Python interpreter into a single executable. This tutorial will guide you through the process of creating an installer using PyInstaller.<\/p>\r\n<p>&nbsp;<\/p>\r\n<p>1. install py installer<\/p>\r\n<pre class=\"language-markup\"><code>pip install pyinstaller<\/code><\/pre>\r\n<p>2. use it<\/p>\r\n<pre class=\"language-markup\"><code>pyinstaller --onefile script.py<\/code><\/pre>\r\n<p>After PyInstaller finishes, the executable will be in the dist folder within your working directory. For example, dist\/script.exe (on Windows) or dist\/script (on macOS\/Linux).<\/p>\r\n<p>Full example:<\/p>\r\n<pre class=\"language-markup\"><code>pyinstaller --onefile --noconsole --upx-dir \"D:\\Documents\\program\\python\\typing tool\" --icon=icon.ico --hidden-import=keyboard --hidden-import=pyautogui --exclude-module=numpy --exclude-module=cv2 typing_tool.py<\/code><\/pre>\r\n<p>&nbsp;<\/p>\r\n<p>UPX is tool to reduce the size of exe: download from <a href=\"https:\/\/upx.github.io\/\">https:\/\/upx.github.io\/<\/a> and paste exe in current directoy&nbsp;<\/p>","category_id":"5","is_private":"0","created_at":"2025-03-24T20:15:49.000000Z","updated_at":"2025-03-24T20:15:49.000000Z","category":{"id":5,"user_id":"1","name":"Python","slug":"python-6gqr","parent_id":null,"created_at":"2023-03-16T12:36:56.000000Z","updated_at":"2023-03-16T12:36:56.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"Converting a Python script into an installer allows you to distribute your program as a standalone executable file that can run on computers - PYthon code to exe (Updated: March 24, 2025) - Read more about PYthon code to exe at my programming site [SITE]","categories":[]}