1

I have created a simple game with python and pygame and I would like to create an executable for each platform, so people don't need to install a lot of dependencies just to try my game. It seems that pyinstaller is what I am looking for, so I have installed it on my Ubuntu machine, where I developed the game. I tried to run it with the following command:

pyinstaller --onefile main.py 

and the executable seems to be correctly created, but when I run it, I get the following error:

Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/usr/local/lib/python2.7/dist-packages/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
    File "/home/loris/Dropbox/Workspace/Python/pyMemory/build/main/out00-PYZ.pyz/pygame", line 99, in <module>
ImportError: No module named base

I don't really know what to do to solve this problem and I can't seem to find someone else with the same one, so is there anything I could check to try to fix this issue?

EDIT:

I succesfully managed to create a 32 bit executable on Windows, so I thought the problem lied in the 64 bit version of python I was using, so I tried to use pyinstaller into a 32 bit Ubuntu virtual machine, but the result was the same.

Pyrox
  • 551
  • 5
  • 17
  • is pygame installed in `/usr/local/lib/python2.7/site-packages`? (I think thats the directory on linux ... can you build the exe on a windows machine? I would recommend 32 bit python by the way(not sure if you are using 64bit python...but I have had issues with 64 bit python executables) – Joran Beasley Nov 07 '14 at 21:34
  • I don't really know where pygame was installed. I simply ran an "apt-get install python-pygame". The directory you provided looks empty. – Pyrox Nov 07 '14 at 21:38
  • IIRC, Ubuntu carefully sets things up so `pip` and `apt` don't step on each other's toes, so `pip install spam` installs into `/usr/local/lib/python2.7/site-packages`, while `apt-get install python-spam` goes into `/usr/lib/python2.7/site-packages`, and both are on `sys.path` with the former coming first. But there's also `site-packages` vs. `dist-packages`, too. – abarnert Nov 07 '14 at 21:40
  • Alright, pygame seems to be located in /usr/lib/python2.7/dist-packages in my machine, if that can be of any help. – Pyrox Nov 07 '14 at 21:43
  • Anyway, I think that, even if you solve this problem, it's still not going to work on anyone else's linux box, because the default pygame packages are shared-linked to SDL, so your game will fail when it can't find libSDL.so and friends. But I could be wrong about that. – abarnert Nov 07 '14 at 21:43
  • Also, you marked this "cross-platform". This is _definitely_ not going to work cross-platform. You're creating a linux/ELF executable that bundles up a linux/ELF build of Python and a bunch of so files; it's not going to run on Windows or Mac or FreeBSD or sufficiently different linux. – abarnert Nov 07 '14 at 21:45
  • 1
    Yes, I marked it in this way because I am planning to "compile" it also on Windows and Mac. – Pyrox Nov 07 '14 at 21:46
  • I know it works well on windows ... but Ive never used pyinstaller on linux ... perhaps you could edit the `program_name.spec` file to force it to include the extra shared libraries (but pyinstaller is usually really good about bundling required shared libs... at least on windows) – Joran Beasley Nov 07 '14 at 22:23
  • I have just tried to build it on Windows and it seems to work. I used a 32bit python installation, so maybe this is the problem... I'll try to investigate more, in the worst case I'll ship 32bit versions only. – Pyrox Nov 07 '14 at 23:16

0 Answers0