Pyinstaller does not create executables for cross-platform purposes, only for the platform on which Pyinstaller runs "natively". However, WINE allows you to run your own Windows Pyinstaller under Linux, so you can use it to create Python scripts developed under Linux in your own Windows.exe executable files using only one Linux host β no separate Windows host is required. These instructions are not for the Mac.
I am using Ubuntu 15.10 on a 64-bit Pentium type.
$ uname -op x86_64 GNU/Linux $ grep DISTRIB_DESCRIPTION /etc/lsb-release DISTRIB_DESCRIPTION="Ubuntu 15.10"
Make sure Python is installed.
$ apt-get install python2.7 [installed OK] $ python --version Python 2.7.10
(upgrade and) use the Python package manager to install, and possibly upgrade Pyinstaller on Linux. Pips starting without superuser privileges can fail.
$ sudo -H pip install --upgrade pip [upgraded OK] $ sudo -H pip install PyInstaller [installed OK] $ sudo -H pip install --upgrade pyinstaller [installed OK] $ pyinstaller --version 3.0
You can install Python / Pyinstaller, install / configure WINE and write Python code in any order (although Python is required to run the code). Using the Python package manager, install the Python packages that are dependent on your Python project.
$ pip install package1 [package2, ...] [packages installed OK]
Check the packaging of the Linux-oriented executable.
$ cd python-project $ pyinstaller --onefile python-project.py [built OK] $ dist/python-project [ran OK]
If it does not build or does not start normally, try creating it as -oneir, Pyinstaller by default, which does not include swap files in one executable file. This should not be built / work differently than the single-file version, but it may be easier to debug onedir, which should then build OK as a single file.
Make sure that WINE is installed and configured to use your chosen target version of Windows (for example, Windows 7):
$ wine --version wine-1.7.50 $ winecfg [GUI: Applications tab > Windows Version: Windows 7]
Use WINE to install Windows Python, pywin32 (Windows GUI extensions); correspond to their versions. You should probably go to each download page for the correct versions and mirrors than these current direct download links. Note that running WINE will reset many WINE error notifications to the console; These are almost all minor in this procedure.
$ mkdir -p /opt/windows $ pushd /opt/windows $ wget https://www.python.org/ftp/python/2.7.10/python-2.7.10.amd64.msi $ wget http://iweb.dl.sourceforge.net/project/pywin32/pywin32/Build%20219/pywin32-219.win-amd64-py2.7.exe $ wine msiexec -i python-2.7.10.amd64.msi $ wine msiexec -i pywin32-219.win-amd64-py2.7.exe $ popd
I was having problems with the Python 2.7.10 MSI wizard being unable to perform "Next" after selecting the installation directory, so I canceled it there and started it again by adding the -qn parameter, which suppresses the graphical interface. It complained a bit, but completed the installation. If you need to find Windows Python in your Linux file system, the default installed in your default Linux directory is WINE "C:" in your home directory, i.e. ~ / .wine / drive_c / Python27.
$ wine C:/Python27/python --version Python 2.7.10 $ find ~/.wine/drive_c -name python.exe ~/.wine/drive_c/Python27/python.exe
Update your Windows package and install Pyinstaller using WINE Python / pip.
$ wine C:/Python27/Scripts/pip.exe install --upgrade pip [upgraded OK] $ wine C:/Python27/Scripts/pip.exe --version pip 7.1.2 from C:\Python27\lib\site-packages (python 2.7) $ wine C:/Python27/Scripts/pip.exe install pyinstaller [installed OK] $ wine c:/Python27/python.exe C:/Python27/Scripts/pyinstaller-script.py --version 3.0
Install Windows Project Packages
$ wine C:/Python27/Scripts/pip.exe install xlwt [installed OK]
Your Python environment for Windows (WINE) is now configured equivalent to your native Linux environment. Running Windows Pyinstaller under WINE creates its own executable file, Windows.exe. Use the Windows Pyinstaller version for the Windows Python script to maintain parity with your proven OK Pyinstaller procedure, against your python project on your Linux file system (this does not need to be copied to the Windows WINE file system). Keeping the Windows build and dist directives separate from the Linux OK under test can help debug the packaging process.
$ wine c:/Python27/python.exe C:/Python27/Scripts/pyinstaller-script.py --onefile --workpath=./win-wrk --distpath=/opt/windows python-project.py [packaged OK] $ ls -F /opt/windows/python-project.exe python-project.exe* $ wine /opt/windows/python-project.exe [Windows app runs OK]