chevron_left chevron_right
Login Register invert_colors photo_library


Stay updated and chat with others! - Join the Discord!
Thread Rating:
  • 0 Vote(s) - 0 Average


Tutorial Python Script to Windows Executable filter_list
Author
Message
Python Script to Windows Executable #1
Just a simple starter guide for those of you who want be able to execute your Python scripts across Windows machines without having to install the Python interpreter on each PC.

We will be using PyInstaller; so you must first install it. (easy with pip)
Code:
pip install pyinstaller
Create a simple Python script named hello.py -- in it, just print out "Hello" or something.
Spoiler:
[Image: Qt47WOC.png]
Open a command window in the folder of your script. Tip:
Spoiler:
Press SHIFT+RIGHTCLICK and choose Open command window here
The syntax to compile your script into an executable is:
Code:
pyinstaller --onefile <script>
Spoiler:
[Image: odBIKSB.png]
And there you have it, in the new sub-folder dist is your executable.
Your executable should be able to work across all newer Windows operating systems. However, you will need to watch out for 32-bit/64-bit... your executable will be compiled as a 32-bit exe if you are running 32-bit Python, and as a 64-bit executable if you you are running 64-bit Python. It would be recommendable to compile to 32-bit, since that will be executable on both 32 and 64-bit Windows.

MORE:
Spoiler:
If you are developing a GUI application, you can use the --windowed argument to hide the console window. Example usage:
Code:
pyinstaller --onefile --windowed <script>
You can set the executable's icon with the --icon= argument. Example usage:
Code:
pyinstaller --icon=img.ico --onefile <script>
WARNING: You may or may not be able to use external libraries.

[+] 1 user Likes m0dem's post
Reply

RE: Python Script to Windows Executable #2
Awesome and simple guide, as someone who uses python a lot this is a +1 Smile
[Image: 9JVyFsC.png]
Sig by @Symadox

XMPP: Mi5@DukGo.com

[+] 1 user Likes Megan's post
Reply

RE: Python Script to Windows Executable #3
(12-05-2015, 09:22 PM)Megan Wrote: Awesome and simple guide, as someone who uses python a lot this is a +1 Smile

Thanks!
I am going to start posting more tutorials. My plan for the next one:
Spoiler:
Hiding Data Inside an Executable

[+] 1 user Likes m0dem's post
Reply






Users browsing this thread: 1 Guest(s)