Here are the steps:
1. Make sure you can run the python code under windows.
If you are running with cuda, make sure the device id is selected correctly, 0/1.
2. Once you can run the python code in windows, next is to install the pyinstaller.
It must be run under python > 3.3 and you can install it as following:
$ pip install pyinstaller
3. Once you have the pyinstaller, next you need to setup a main.spec.
Assume your python code is main.py.
You can create a main.spec file as following:
# -*- mode: python -*- #filename = Main.spec import sys myLibPath = './libs' sys.path.append(myLibPath) a = Analysis(['Main.py'], pathex=['/Users/.../ProgramNameDir'], hiddenimports=[], hookspath=None, runtime_hooks=None) pyz = PYZ(a.pure) exe = EXE(pyz, Tree('img',prefix='img'), a.scripts, a.binaries, a.zipfiles, a.datas, name='Main', debug=False, strip=None, upx=True, console=False , icon='mainIcon.ico') app = BUNDLE(exe, name='Main.app', info_plist={ 'NSHighResolutionCapable': 'True'}, #<-- Option for High Resolution icon='mainIcon.ico')
4. Once you setup the main.spec, then you are all set and ready to compile it.
Run the following command to convert main.py into main.exe.
Output will be generated in two folders, build and dist.
You only need to look at the dist folder > main.exe.
$ pyinstaller main.spec
5. During compilation, you may receive some errors.
Most probably is due to the missing packages under python.
For example, I need to run the following code to install some packages.
$ pip install setuptools --upgrade
$ pip uninstall six
$ pip install six
$ conda install --channel https://conda.anaconda.org/bpentz pyqt5
6. Once compilation completed, congratulations, you are done.
You can navigate to root > dist > main.exe.
If you running the main.py with some additional files, remember to copy into dist folder.
You may run the exe in cmd to see the errors.
p/s: I remembered the compiled exe cannot be used for commercial purpose as it uses some Microsoft dll or licensed dll, please be aware.