Search code examples
python-3.xpy2exepython-importlib

Python 3 Can't makes importlib works with py2exe or cxfreeze


My code is working fine when i run it with python but if i try to use py2exe or cxfreeze importlib module isn't working, and i've been looking for a while now to get it working..

heres the part of my code not working (im 99% sure its):

idm = cc.GetModule("idmantypeinfo.tlb")
name = str(idm)
module = name[9:65]
IDMan = importlib.import_module(module)

this works with python via console, but it instantly crash when compiled after it calls IDMan:

idm1 = cc.CreateObject("IDMan.CIDMLinkTransmitter", None, None, IDMan.ICIDMLinkTransmitter2)

this is because of that part :

module = name[9:65]
IDMan = importlib.import_module(module)

which should give me an object but after compiling with py2exe or cxfreeze (even pyinstaller) it just gives me a string because importlib isn't working i've no idea how to fix that..


Solution

  • Finally got it working with cx, i simply forgot to link the build options.. included comtypes & importlib, problem solved.