Python module import problem [SOLVED]

This forum is currently in read-only mode.
From the Asset Store
Instantly Create Rogue-like Adventures with just 1 Layout! Include this IGM into any existing games.
  • Hi there! (ah, so I finally joined the forum, sorry to post a problem as my first post)

    Me and my little indie game team are working on some projects, and we use CC as our primary app, mostly due to it's Python support, which really adds power and flexibility. Until now it went smoothly enough, but suddenly, a little something came up. I'll get into details right now (after this ad!):

    • we're using a separate "PYTHON Event Sheet" that is imported at a start of every layout
    • the "PYTHON ES" contains all classes and default functions, as well as import module lines
    • it works OK in most cases, imported string, math, random, time modules without any problem

    The problem is: I can't import base64 module! Nothing I try works, and Aptana Studio imports and uses base64 without any problem. Rest of the modules work pretty well, never had this error before. It's ImportError: no module named base64.

    Any suggestions? Does Construct need to have these modules in a specific location? Or does it just hate base64? :P Any help would be greatly appreciated! Cheers!

    Edit: SOLVED! For all those who will encounter this problem in the future: Construct Classic seems to come with some of the modules stored in <CC path>\Data\Python but not all of them. If you encounter an "ImportError: no module named XYZ" that means that it's missing it in that directory. You can add manually the *.pyc file to this directory, but it has to be Python 2.6 and not a higher version. I tried to copy a Python 2.7 base64.pyc and that gave me the "magic number" error - the versions were not compatible. So, I downloaded Python 2.6 installation and found that all modules were *.py and not *.pyc. I wrote a small compiler [import py_compile / py_compile.compile("base64.py")], and made a *.pyc out of the base64.py. Then, copied it to the CC\Data\Python directory and it works like a charm!

    Sorry for the messed up description, I hope it will become handy to someone. Cheers!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay... i tried to copy the base64.pyc from my Python installation folder (I use Python 2.7) to Scirra\Construc Classic\Data\Python but now it gives me... an ImportError: Bad magic number in ..\Data\Python\base64.pyc.

    Is there... magic involved? I need a witch doctor!

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