-1

Can a python 3 script be compiled in a linux environment in such a way as it can be run under Windows? If so what compile tool? ie. py2exe or pyinstaller ect.

  • 1
    Possible duplicate of [Cross-compiling a Python script on Linux into a Windows executable](https://stackoverflow.com/questions/2950971/cross-compiling-a-python-script-on-linux-into-a-windows-executable) – Aaron Mar 23 '18 at 13:33

1 Answers1

0

You're looking for cross-compilation, and the answer is no.

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 Windows binaries while running under OS X?
No, this is not supported. Please try Wine for this.

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.

You may use Wine or the Windows Subsystem for Linux to attempt using PyInstaller to build stand-alone binaries for different operating systems, however, neither PyInstaller, nor Py2Exe, nor cx_freeze, nor any tool to my knowledge does this. Effectively, in-order to do something like this, you would need a cross-compiler such as MinGW or VC++ for Linux, and integrate it into PyInstaller, which is very far outside of the scope of the project. It is much easier to use WINE or having a dual-boot system or multiple development computers.

Alex Huszagh
  • 13,272
  • 3
  • 39
  • 67