Forum: Poser Python Scripting


Subject: Mac Python cannot find modules added under Runtime/Python unless sys.path manual

an0malaus opened this issue on Oct 06, 2012 ยท 2 posts


an0malaus posted Sat, 06 October 2012 at 7:34 AM

Hi all, I'm especially pleased to see that the snake-heads I respect most are getting to grips with wxPython UI issues on the Mac, in the absence of TkInter support under PPro2012. I frequently find, however, that python modules (defined by a folder/directory named for the module and containing an init.py file) are not found when they are located within the application's default Runtime:Python folder.

It seems very strange to me that the folder containing the module appears in the sys.path if I print it from the python shell, yet attempts by launch scripts which try to import the named module fail with "ImportError: No module named blah" errors. The vagaries of Python on the Mac seem to dictate that the folder containing the module named folder itself must be in sys.path or the module is deemed not to have been found. Indeed, if I execute sys.path.append('Applications/Poser Pro 2012/Runtime/Python'), a subsequent attempt to reference any module which resides in a folder within that directory will succeed.

This does seem logical, but I can only assume that it must work differently on windows as I don't see any complaints about the many free scripts that are distributed as modules.

I assume it would be possible to perform this sys.path.append within the launch script, but I wonder why it isn't being done as a matter of course. Again, I assume it's not required on windows systems.



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


PhilC posted Sat, 06 October 2012 at 8:03 AM

I hear you :)

I always use ....................

sys.path.append(pathname)

................ to ensure import success.

See the Wardrobe Wizard Menu.py in poserScriptsScriptsMenu for an example.