Python issue with Random.py when exporting only!

This forum is currently in read-only mode.
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Hi

    Please forgive my first post being a problem but honestly I'll really appreciate anyone who could help...

    The issue I have that is driving me mad is I can run my game fine from within construct.

    When I export my game however, it throws an error that it cannot find "random.py", if I find a random.py from somewhere off the internet, it trys the file and doesn't like it. I assume really it should be after random.pyc (the complied bytecode version I'm pretty sure it should be using) but it is not

    Here's some example code that should reproduce the issue:

    import random

    random.seed(1)

    y = random.randint(0,99)

    Text.SetText(y)

    Here's an example cap:

    dl.dropbox.com/u/3998493/BugTest.cap

    It's very fundamental to my game as I am deliberately using random seed to create predictable but "random" patterns.

    If anyone can help it'd be most appreciated, I am new to Python and so far it's very impressive but I am now worried all this work and I can't share my game <img src="smileys/smiley19.gif" border="0" align="middle" />

  • ***UPDATE***

    I have since found that having a Python26 directory and python installed is a requirement for anyone running the game

    either that or i seem to be able to dump the lib folder in the game directory and it works somehow... so i am on the right track, if anyone has anything to add please do

  • When you export to exe check the enable python checkbox and select all the python files you want included in your exe. Alternatively you can copy the python files you use to the same folder as your exe.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • for some reason it won't, it bundles the dll for python not the libs

    but i chucked the hole lib folder for python in my distribution, later on I will prune it down hopefully

    thanks for your reply, I am psyched about his program, amazing performance, python can just dump out a 1000 sprites in a second, bullet hell is not really possible on HTML 5

  • You won't see the bundled python files since they are embedded into the exe. I did a further test and this is a list of all the python libs you need to check when you export:

    __future__.pyc

    _abcoll.pyc

    abc.pyc

    copy_reg.pyc

    genericpath.pyc

    linecache.pyc

    ntpath.pyc

    os.pyc

    random.pyc

    stat.pyc

    StringIO.pyc

    types.pyc

    UserDict.pyc

    warnings.pyc

    I found this by running this script at the start of the layout:

    sys.path=sys.path[-2:-1]
    import random

    Then exporting to an exe, running the exe, and if it can't find a lib re-export with that lib included and repeat.

    Once you get it working you can remove the line with sys.path.

    Here is another way of finding out what files need to be included:

    http://www.scirra.com/forum/python-external-libraries-w-ai-speech_topic39525.html

  • i just tried it and it worked!

    I think I will also choose the trial and error method, I realize now I was looking for some external file when it gave me that message, I though maybe I had to bundle them together as I'd got away with chucking a python.dll in there

    thanks for helping me with that, it's very satisfying to have it all in the exe now :)

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