3

I created a game using pygame, and I wish to export it to a .exe file. I've used pyinstaller for this, as it is available for Ubuntu. When I run the --onefile game, it works perfectly fine (on my ubuntu computer). However, when I send it to my friend who has windows, it is NOT a Windows executable, but simply a "file" without any extension. He cannot run it. Renaming it Game.exe has not worked either.

I'm out of ideas... can anyone help?

6
  • It should be kind of obvious that Ubuntu binaries are not the same as Windows'? Feb 26, 2016 at 23:33
  • PyInstaller's purpose is to create a .exe file from a .py file, isn't it?
    – ruyili
    Feb 26, 2016 at 23:36
  • 1
    Under Windows. But under Linux it produces Linux binaries, of course. Feb 26, 2016 at 23:51
  • Oh. Because when I right click the file and select "Properties", it tells me that it is an x-executable. How would I make it a windows executable?
    – ruyili
    Feb 26, 2016 at 23:57
  • You could run pyinstaller's Windows version through Wine. Maybe that'll do it. Feb 27, 2016 at 0:13

2 Answers 2

6

Obviously the binary executable generated by PyInstaller on Linux only runs on Linux and not on other operating systems like Windows. The file name extension is irrelevant here.

According to the PyInstall FAQ you cannot use it to cross-compile for different platforms either, but running PyInstall inside Wine is supposed to achieve what you want:

  1. Can I use PyInstaller as a cross-compiler?
    1. 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.

From what I understand, you'll need to install PyInstall inside a Wine environment like you would in Windows and then use it like you would on a native Windows system. Please refer to How can I install Windows software or games? for an overview of how to get started with Wine on Ubuntu.

1
  • 1
    How would I run PyInstaller on Wine? There's not a .exe file I can find. Sorry, I'm (really) new to Ubuntu.
    – ruyili
    Feb 28, 2016 at 20:48
1

You can try Python Packager

The git homepage gives the instruction (python 2.7):

wget "http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi" 
wget "http://nchc.dl.sourceforge.net/project/pywin32/pywin32/Build%20218/pywin32-218.win32-py2.7.exe"
build_environment/create.sh
export WINEPREFIX=/tmp/path-outputted-from-create
wine start python-2.7.3.msi
wine pywin32-218.win32-py2.7.exe
build_environment/freeze.sh
./package sample-application/src/main.py MySampleProgram

This will build a separate wine environment and installs Python 2.7 as mentioned. In case you need another version, got to the python homepage and download your version.

You can also follow this instruction which downloads a wine-clone:

git clone https://github.com/paulfurley/python-windows-packager
./python-windows-packager/package.sh /path/to/myProject
1
  • Just a heads up, as of late 2018 the maintainer of the Python Packager says is one on the open issues on the project that he has abandoned it. May 22, 2021 at 22:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .