On 12-dec-2005, at 20:48, Zhi Peng wrote: > > Thanks Ronald and everyone. My OS is Tiger. This shows > me that my Python installation or default has been > changed or something is missing for sure. It is > strange for me to see this type of results.
What's the output if you insert a call to PyErr_Print on the line that start with "if(!myMod)" (e.g.: if(!myMod) { printf("cannot import StringModule wave\n"); PyErr_Print(); return TRUE; } Please use the version in my zipfile and run 'make' to build and run the ScriptSupport program. Ronald > > > Regards > > Zhi > > > --- Ronald Oussoren <[EMAIL PROTECTED]> wrote: > >> >> On 12-dec-2005, at 19:30, Zhi Peng wrote: >> >>> Hi! All >>> >>> If you use MacPython2.3 on MAc, please try the >>> following code to see if you can get >> "StringModule" >>> imported. >> >> This works for me, run see the attached zipfile for >> the code I used. >> The only change I made was an additional printf to >> demonstrate that >> the module is indeed imported by print its repr(). >> >> This is on OSX 10.4.3. >> >> BTW. I had to reformat the makefile and C code >> because those got >> mangled along the way, I prefer to include complete >> code examples in >> an archive. >> >> Ronald >> >>> >>> >>> >> > //=============================StringModule.py=========== >>> #!pythonw >>> >>> import os >>> >>> class Module1: >>> def __init__(self): >>> self.var1= 9 >>> def method1(self): >>> self.var1=10; >>> >>> >>> >>> >>> >>> //========================= makefile >>> ==================== >>> YLIB = >>> >>> >>> PYINC=-I./ -I/usr/include -I/usr/include/python2.3 >>> LIBS =-L/usr/lib -ldl -lm -lpython >>> >>> OPTS= -Wall -Wstrict-prototypes >>> >>> PROGRAM=ScriptSupport >>> ScriptSupport::ScriptSupport.o >>> gcc -g ScriptSupport.o $(LIBS) $(PYLIB) -o >>> ScriptSupport >>> ScriptSupport.o:ScriptSupport.c >>> gcc -g ScriptSupport.c -c $(PYINC) $(OPTS) >> -o >>> ScriptSupport.o >>> clean: >>> rm -f $(PROGRAM) *.o core >>> >>> >>> >>> >>> >>> //================ ScriptSupport.c >>> ======================== >>> >>> #include <Python.h> >>> >>> #define FALSE 0 >>> #define TRUE 1 >>> >>> int main(void) >>> { >>> PyObject *myMod=NULL; >>> >>> >>> Py_Initialize(); >>> >>> PyRun_SimpleString("import sys \n"); >>> >>> >> PyRun_SimpleString("sys.path.append('.\')\n"); >>> PyRun_SimpleString("print sys.path \n"); >>> >>> //#myMod=PyImport_ImportModule("wave"); >>> >>> >> myMod=PyImport_ImportModule("StringModule"); >>> if(!myMod) { printf("cannot import >>> StringModule wave\n"); return TRUE; } >>> >>> Py_Finalize(); >>> >>> return 0; >>> } >>> >>> >>> __________________________________________________ >>> Do You Yahoo!? >>> Tired of spam? Yahoo! Mail has the best spam >> protection around >>> http://mail.yahoo.com >>> _______________________________________________ >>> Pythonmac-SIG maillist - >> Pythonmac-SIG@python.org >>> >> > http://mail.python.org/mailman/listinfo/pythonmac-sig >> >> > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig