On 11/08/2010 5:38 AM, Marc-Andre Belzile wrote:
Hi,
I'm using the Python ActiveX Scripting engine and I'm trying to set some
global variables in the engine global space before parsing some .py
files. I use this function to set the variables:
def set_global_vars(fullpath ):
import os
globals()['__path__'] = os.path.dirname( fullpath )
globals()['__file__'] = fullpath
It seems to work with my python installation (py2.6/pywin 212) but some
customers of mine have reported an error with this line below (using a
similar installation)
from win32com.client import dynamic as D
# ERROR : Traceback (most recent call last):
# File "<Script Block 2>", line 1, in <module>
# from win32com.client import dynamic as D
# SystemError: Parent module '__ax_main__' not loaded
Obviously, if set_global_vars is skipped, the error doesn't show up.
Any ideas why would this error happen ?
Probably because you are overriding __path__ and __file__ for a module,
but the module loader uses those attributes? Is it possible your client
is using a different Python version? FWIW, the
win32com.axscript.client.pyscript module is what attempts to create a
new module called __ax_main__
Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32