Exported EXE gives Python error

This forum is currently in read-only mode.
From the Asset Store
Use this game pack to create your own game, modify the existing game or simply take a look and see how it was made.
  • 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:

    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:
    
    [i]Traceback (most recent call last):
    File "<string>", line 1, in <module> 
    File "random.pyc", line 43, in <module>
    ImportError: No module named warnings[/i]
    
    Can someone please point out what I'm doing wrong?
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)