These are the steps that allowed me to freeze a simple Python script to a Windows executable.
(edit this graphic on draw.io)
These steps will guide you towards your very own .exe file.
You must be able to run Windows containers for Docker.
One way to achieve this is with the excellent StefanScherer/windows-docker-machine repository.
This works for Windows, macOS and GNU/Linux, because Vagrant runs on all three.
The 2016-box
will suffice.
git clone https://github.com/tssmits/docker-python-exe
cd docker-python-exe
docker build -t buildtools2017:latest -m 2G .
docker run -v C:$(pwd):C:/exampledir buildtools2017 -it
Now that you're in the running Docker container, please surf to the example script.
cd exampledir
Please initiate a virtualenv.
python -m venv venv
Activate it.
.\venv\Scripts\activate
Now you can install the required packages.
pip install pyinstaller
Just one more command and your .exe is ready!
pyinstaller --onefile hello.py
You can now run the .exe file.
.\dist\hello.exe
You can ignore these warnings. The .exe will still run. Read more about this issue at pyinstaller/pyinstaller#1566.