Import Error within Python Win32 COM object

Steve Holden sholden at holdenweb.com
Tue Oct 23 16:52:33 EDT 2001


"Sue Giller" <sag at hydrosphere.com> wrote in message
news:mailman.1003866863.7586.python-list at python.org...
> I am trying to create a Win32 COM server object out of a python
> class and use it in a VB application.
>
> import win32com.server.register
> win32com.server.register.UseCommandLine(DataSetMaker)
>
> I can get the python object to properly import and use some Python
> modules, but not others.  It would appear that modules that live in the
> Lib directory get found (such as string, cpickle, urllib), but other that
> are in the Python path but not in Lib (such as Numeric) do not.  I get
> an ImportError:  No module named Numeric...
>
> For example, this function works just fine
> def _getURL(self):
>         import urllib
>         import string
>        <code ....>
>
> But, if I add `import Numeric` to it, I get the error.  The module runs
> just fine as a simple python class module - it finds all imports,
> whether run from PythonWin or DOS.
>
> Any ideas?
>
> Is there a discussion about the rules/caveats for importing Python
> classes inside a server object, even tho those classes are not
> exposed to the outside world?
>
When import stops working (I'm presuming it works when Python is run
normally) the first place to look is sys.path. Have you printed that out
from your COM objedct? Just open a file for writing and dump using "print >>
file, sys.path".

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list