Help with PyGame dependencies

For questions about using Classic.

Post » Fri Mar 04, 2011 8:30 am

I made a simple cap to play music with pygame.mixer, it works fine, but when I export exe and rename Python directory it says something like
"File "pygame\__init__.pyc in <module>
...
ImportError, DLL load failed"
I put pyexpat.pyd and _socket.pyd into my export directory, also I put pygame library into construct\python directory and checked all .pyc files in python export dialog
I followed Scidave's Python Libray Quick Guide, it says "Unzip the standard-aiml.zip file into the export directory", but what I should do with pygame since I can't see anything like "standart_pygame.zip" here?
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Sat Mar 05, 2011 6:48 am

bump
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Sat Mar 05, 2011 4:33 pm

Try these two references and then let us know if you still have problems...

viewtopic.php?f=3&t=7258&hilit=pygame

viewtopic.php?f=16&t=7196
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sun Mar 06, 2011 9:48 am

I feel so stupid, but still cant figure it out. If I follow examples and tutorials it works fine, but not with PyGame.
I just started to learn Python and don't fully understand this module stuff.
Can you make exemple of compiled ready-to-distribute construct&pygame app with cap source, please?
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Sun Mar 06, 2011 8:25 pm

Try this first:

http://www.box.net/shared/kcoxzzt7bz

Unzip everything in the "library" sub directory under library_pygame.zip into your Construct/Python folder. Then go ahead and re-export your .cap file and click all of the embedded .pyc files.

Then in your directory where you have exported the .cap file copy everything from the pygame_modules.zip file into the same directory as the .exe.

If that doesn't solve it then, I'll go ahead and work up an example....but as far as a .cap goes it would be a basic .cap with the library_pygame.zip file.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sun Mar 06, 2011 10:07 pm

I tried this zip, and also I tried cx_freeze and py2exe generated dependencies
[quote:10xw7idu]copy everything from the pygame_modules.zip file into the same directory as the .exe.[/quote:10xw7idu]
When I do this, it don't run even with not-renamed Python directory!
Maybe problem with my code:
[code:10xw7idu]sys.path.append(System.AppPath)
from pygame import mixer;
mixer.init();
mixer.music.load (System.AppPath+'5.xm');
mixer.music.play(-1);
[/code:10xw7idu]
?
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Sun Mar 06, 2011 10:46 pm

Also, screenshot
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Mon Mar 07, 2011 12:35 am

Here is a working example:
[url:1xppsw6o]http://dl.dropbox.com/u/5426011/examples4/pygamemixerEX.zip[/url:1xppsw6o]

When exporting the only python library that needs to be selected is "stringIO.pyc". Also put the "py" directory in the same folder as the exported exe.
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739

Post » Mon Mar 07, 2011 7:47 am

Now it works, thanks.
Is pyc. to .exe including broken?
How can I figure out which pyc. and pyd. files I need if I gonna use other pygame modules? (py2exe and cx_freeze generates too many files)
Should I put everything from library_pygame.zip\library to py subfolder and everything from pygame_modules.zip to pygame subfolder if I want to use whole PyGame?
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Mon Mar 07, 2011 1:16 pm

[quote="DtrQ":tc4lc0dy]Is pyc. to .exe including broken?[/quote:tc4lc0dy]
It shouldn't be, but I haven't tested with the latest build. If Rojo did it then it should work.

[quote="DtrQ":tc4lc0dy]How can I figure out which pyc. and pyd. files I need if I gonna use other pygame modules? (py2exe and cx_freeze generates too many files)[/quote:tc4lc0dy]
This is a tricky one. If your program doesn't use much Python then you may be able to not include any other .pyc and just include the .pyd module that relates... For example, if you use ctypes then you would include _ctypes.pyd. The reason why I listed checking all of the .pyc files is that if you have a complex program it requires lots of dependencies and it is easier to have a slightly larger .exe than to manually fix all of the dependencies (i.e.get an error, check another .pyc, build and then resolve next error). For .pyd one way to solve that is to just remove them one by one until you get an error. That is what I usually do...takes a few minutes but you only have to do it once.

What Rojo did with the "py" directory is he included what you need to get Pygame working (much better than me :-) I might say). So if you use his approach, you don't need to bother with my library_pygame.zip or pygame_modules.zip. Of course, if you add new Python or Pygame functionality then you should use cxfreeze to match ROjos method. Whatever stuff that cxfeeze says you need you should bundle that into a py.zip file like what Rojo did. You may get a few extra files, but it shouldn't be too many.

ROjo are you using a different method?
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests