Skip to content

Instantly share code, notes, and snippets.

@dayvsonlima
Created June 5, 2017 01:51
Show Gist options
  • Save dayvsonlima/5624cc5b2033379ae969970dd1293a5e to your computer and use it in GitHub Desktop.
Save dayvsonlima/5624cc5b2033379ae969970dd1293a5e to your computer and use it in GitHub Desktop.
generate windows .exe in python

As mentioned by other answerers, the cross-compilation feature is removed from PyInstaller since 1.5. Here, show how to package a Windows executable from Python scripts using PyInstaller under wine.

Step 1: Install wine and Python

sudo apt-get install wine wine msiexec /i python-2.7.10.msi /L*v log.txt PS: Newer Python versions already include pip (is used to install pyinstaller). Download Python installation package from here (e.g., python-2.7.10.msi)

Step 2: Install PyInstaller on wine

$ cd ~/.wine/drive_c/Python27 $ wine python.exe Scripts/pip.exe install pyinstaller

Successfully installed pyinstaller-3.1.1 pypiwin32-219 Step 3: Package Python scripts

Package Python scripts (e.g., HelloWorld.py) with pyinstaller.

$ wine ~/.wine/drive_c/Python27/Scripts/pyinstaller.exe --onefile HelloWorld.py

filename: HelloWorld.py

#!/usr/bin/env python

-- coding: utf-8 --

print('Hello World!') The Windows executable file is located in dist/.

$ wine dist/HelloWorld.exe Hello World! fixme:msvcrt:__clean_type_info_names_internal (0x1e24e5b8) stub Refer to here for the detailed description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment