Exported EXE gives Python error

For questions about using Classic.

Post » Fri Jan 21, 2011 4:58 am

If I use python script to do basic things then the EXE runs fine as long as the python26.dll is in the folder.

But I just tried using the random module and the exported EXE no longer works eventhough it runs fine within Construct.

My test script is very simple:

[code:djpa2kif]import random

SEED = 123
random.seed(SEED)
System.SetGlobalVar('x', random.randrange(0, 100))[/code:djpa2kif]
When I run the EXE it complains something about random.pyc and about not finding __future__

So in the export wizard I tried checking the __future__ and random.pyc modules, which fixed the __future__ error but not the "random" one.

The error message it gives me is:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "random.pyc", line 43, in <module>
ImportError: No module named warnings


Can someone please point out what I'm doing wrong?
B
3
S
1
G
4
Posts: 42
Reputation: 1,609

Post » Wed Jan 26, 2011 9:39 am

There are a lot of modules you need to tick when exporting, because they build the basic functionality of Python. The easiest two ways are:
1) Just tick every pyc or pyo, this will work although there is a small overhead of never needed modules embedded in the exe
2) Trial&error, in your example error message, it wants warnings.pyc, so tick it export again and see the next error message to find the next module to embed, and so on, until there is no error message anymore.

Most basic modules almost always needed are
__future__
abc
collections
functools
genericpath
locale
ntpath
os
stringIO
traceback
types
warnings

But this is not a complete list. Many modules depend on each other, so when using one module you might need to include a handful of other modules as well.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests