Packaging a Python script on Linux into a Windows executable
Did you look at PyInstaller?
It seems that versions through 1.4 support cross-compilation (support was removed in 1.5+). See this answer for how to do it with PyInstaller 1.5+ under Wine.
Documentation says:
Add support for cross-compilation: PyInstaller is now able to build Windows executables when running under Linux. See documentation for more details.
I didn't try it myself.
I hope it helps
How can I make a Python script standalone executable to run without ANY dependency?
You can use py2exe as already answered and use Cython to convert your key .py
files in .pyc
, C compiled files, like .dll
in Windows and .so
on Linux.
It is much harder to revert than common .pyo
and .pyc
files (and also gain in performance!).
Executable Python program with all dependencies for Linux
Use PyInstaller in Linux based systems
PyInstaller is a program used to convert Python scripts into standalone deployable applications.
Install PyInstaller from PyPI:
pip install pyinstaller
Go to your program’s directory and run:
pyinstaller yourprogram.py
This will generate the bundle in a subdirectory called dist
You can use
-onefile
argument in order to generate the bundle with
only a single executable file.
Build Python Standalone Executable for Linux using Windows Machine
No, there is no way to do this with PyInstaller and just a Windows development machine.
PyInstaller creates executables for the system you're running it on. If you run it on a Windows machine, you get a Windows executable.
In the past, I solved this problem by creating a Linux development VM, and running PyInstaller there; it creates a Linux executable appropriately.
Compile python script on Windows for Linux use
pyInstaller
is not intended to be used as a cross-compiler, and has no support for doing so. In fact, this is the first answer in the FAQ:
Can I use PyInstaller as a cross-compiler?
Can I package Windows binaries while running under Linux?
No, this is not supported. Please use Wine for this, PyInstaller runs fine in Wine. You may also want to have a look at this thread in the mailinglist. In version 1.4 we had build in some support for this, but it showed to work only half. It would require some Windows system on another partition and would only work for pure Python programs. As soon as you want a decent GUI (gtk, qt, wx), you would need to install Windows libraries anyhow. So it's much easier to just use Wine.
Can I package OS X binaries while running under Linux?
This is currently not possible at all. Sorry! If you want to help out, you are very welcome.
Of course you're asking if you can package Linux binaries while running under Windows, but, as you can guess, the answer is the same.
Even though pyInstaller
itself can't do this, that doesn't necessarily mean it's impossible; it's just that it would be ridiculously hard.
So, what can you do? Well, one obvious possibility is to run a virtual machine with Linux (or User-Mode Linux, or something similar). Then, just share the source directory with the virtual machine, ssh into the virtual machine, and run pyInstaller from there.
Related Topics
Python Ftp Get the Most Recent File by Date
Use the Default Python Rather Than the Anaconda Installation When Called from the Terminal
List of Lists Changes Reflected Across Sublists Unexpectedly
How to Print Without a Newline or Space
Why Does Comparing Strings Using Either '==' or 'Is' Sometimes Produce a Different Result
How to Read/Process Command Line Arguments
Get Statistics For Each Group (Such as Count, Mean, etc) Using Pandas Groupby
Understanding Generators in Python
Passing HTML to Template Using Flask/Jinja2
Python Subprocess.Popen "Oserror: [Errno 12] Cannot Allocate Memory"
How to Install Pyodbc on Linux
What Are Metaclasses in Python
Running Shell Command and Capturing the Output
How to Put a Variable'S Value Inside a String