Python issue with Random.py when exporting only!

For questions about using Classic.

Post » Sun Oct 28, 2012 1:09 am

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:
https://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 DarkShroom2012-10-28 01:30:55
B
4
Posts: 31
Reputation: 412

Post » Sun Oct 28, 2012 2:13 pm

***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
B
4
Posts: 31
Reputation: 412

Post » Sun Oct 28, 2012 7:44 pm

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.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Mon Oct 29, 2012 4:21 pm

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
B
4
Posts: 31
Reputation: 412

Post » Mon Oct 29, 2012 6:09 pm

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:
[code]sys.path=sys.path[-2:-1]
import random[/code]
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
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Mon Oct 29, 2012 8:05 pm

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 :)
B
4
Posts: 31
Reputation: 412


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests