- Compile python to exe windows .exe#
- Compile python to exe windows install#
- Compile python to exe windows portable#
- Compile python to exe windows code#
![compile python to exe windows compile python to exe windows](https://upload-images.jianshu.io/upload_images/8103938-bc8dcdc1f8d755f2.png)
![compile python to exe windows compile python to exe windows](https://lh3.googleusercontent.com/_55uSCYxbQ8M/TVLE-Z03hHI/AAAAAAAAAxc/YnkqyU25rUo/8.jpg)
Compile python to exe windows install#
Download & install a specific version of Python.PyInstaller is a handy tool to easily create executables from python files.Have you ever built a Python app and wanted to share it with your non-developer friends? Generally, this is what you would typically go through to set up a Python app on a fresh new machine:
Compile python to exe windows portable#
Once you have created the executable, it is self-dependent and portable to other windows systems. Either way, since Pyinstaller will bundle python interpreter and modules required to run your python script, the size of your executable will be much larger than your python script. If you don’t use –onefile option, then Pyinstaller will create a list of folders with all dependencies. It is important to note that PyInstaller will create an executable file and not an installer for your Python file. If your python script does not use any windows application like tkinter, then you will see the output in a console window. If you get an error message, you may need to install Visual C++ Redistributable. In our case, you will see the following window with a button ‘Click Me’ that you can click to view ‘Hello World’ message. You can double click it to run your Python program.
Compile python to exe windows .exe#
exe file with the same filename as your python script, that is, hello.exe in our case. spec file, and 3 folders build, dist and _pycache_ in the same folder where your python script is located. You will see all the files & folders that Pyinstaller bundles into the executable. If you are really curious about the contents of your pyinstaller output, then create a copy of your python script in another folder, and call pyinstaller in that folder, without –onefile option. It will collect the copies of all those modules including your python interpreter and puts them all in a single file, or folder, depending on whether you use –onefile option or not.
Compile python to exe windows code#
Else PyInstaller will create a folder of files.īasically, when you run the above command, pyinstaller will analyze your code, find out the various libraries and packages required by your code to execute.
![compile python to exe windows compile python to exe windows](https://www.wikihow.com/images/3/37/Compile-Python-Script-Step-6.jpg)
Please remember to use –onefile option to convert it into a single. Replace hello.py with the name of your python script. Next, run the following command on your python script. Go to the folder which contains your python script hello.py. Now that we have PyInstaller installed and our python script ready, we will proceed with the task of converting it into executable. Label1 = tk.Label(root, text= 'Hello World!', fg='green', font=('helvetica', 12, 'bold'))Ĭanvas1.create_window(150, 200, window=label1)īutton1 = tk.Button(text='Click Me',command=hello, bg='brown',fg='white')Ĭanvas1.create_window(150, 150, window=button1)įor our example, we will save the above code as hello.py at C:\Users\John\Desktop\MyPython.
![compile python to exe windows compile python to exe windows](https://ourcodeworld.com/public-media/articles/articleocw-57f3ea34a4400.jpg)
import tkinter as tkĬanvas1 = tk.Canvas(root, width = 300, height = 300) If you already have a python script you want to convert into executable, then you can skip this step and use your python file in next step. If you have not already created python script, you can create one with a sample code below. PyInstaller package bundles your Python file along with its dependencies into an executable.