Share a Python script as Win exe file
Python is installed in Linux and Mac with the OS. Current versions of Linux have both Python 2.7x and 3.x installed along with the OS. The latest Mac OS I checked still had Python version 2.7. When you type Python on the Terminal of a Mac it would load the Python environment with a warning that version 2.7 will be soon be outdated.
Running a Python script on Windows requires one to install Python. Python myscript.py will run the script. This is always a problem when I wanted to share my scripts with colleagues. So I looked for a way to convert them to a Windows executable file. Luckily python has a module called pyinstaller.
Step 1. Install Pyinstaller.
Assuming you have pip installed in your python.
pip install pyinstaller #I sugegst create folder with the name of your script and have the script #inside it. Navigate to that folder unless you want to supply the complete #file path. pyinstaller --onefile myscript.py
This will compile the python script into a binary file, which is stored inside a folder called dist.
The exe file can be shared with any one who can run it in Windows. But wait exe files are harmful to share without digitally signing them. Any endpoint security will consider them malicious and kill/quarantine them. Here is an article I wrote for digitally signing Windows exe files.