[Pythonmac-SIG] Mac PyImport_ImportModule("modulename")

Bob Ippolito bob at redivi.com
Sat Dec 10 06:20:47 CET 2005


Well I have no idea whether you're extending or embedding Python..  
and if you are embedding, I have no idea what steps you've taken to  
initialize the interpreter... so I'm not sure.

Like I said before, what you need to do is make absolutely sure  
you're using the correct Python interpreter, framework, or dylib and  
also make sure that sys.path is setup properly.  This might help::

	PyRun_SimpleString("import sys\nprint sys.path\nprint sys.version 
\nprint sys.executable\n");

-bob

On Dec 9, 2005, at 8:45 PM, Zhi Peng wrote:

> Hi! Bob
>
> I have not tried to append current directory in sys.path. Maybe I  
> need to do sth
> sys.path.append("./") and then do import. The module is installed  
> in MacPython package. The os module is in python23.dylib so it can  
> find it and import it. But my module is just a py file.
>
> Thanks
>
>
> Zhi
>
> Bob Ippolito <bob at redivi.com> wrote:
>
> On Dec 9, 2005, at 4:41 PM, Zhi Peng wrote:
>
> > In my c code, I have used myMod=PyImport_ImportModule("moduleName")
> > and run on Mac, but it just can not import the "moduleName" for
> > some unknown reason.
> >
> > I am sure I install the "moduleName" by "pythonw setup install".
> > And I can import "moduleName" from command lines such as
> >
> > >pythonw
> > >import moduleName
> > >
> >
> > It is fine. I wonder why PyImport_ImportModule can not import it,
> > while it can import module os by using
> > PyImport_ImportModule("os")
> >
> > Any suggestion?
> >
>
> Are you sure it's the same version of Python, and the module is on
> sys.path? Check sys.version and sys.path
>
> -bob
>
>
>
> Yahoo! Shopping
> Find Great Deals on Holiday Gifts at Yahoo! Shopping
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig



More information about the Pythonmac-SIG mailing list