On Fri, 2006-08-04 at 11:10 +0800, yy x wrote: > hi,all, > > > > the content of a.py : > #coding:gb2312 > #/usr/local/bin/python > import random > print random.randint(0,10) > > the c program: > #include <Python.h> > int main() > { > Py_Initialize(); > PyRun_SimpleString("import sys"); > PyRun_SimpleString("sys.path.append('.')"); > > PyRun_SimpleString("import a"); > Py_Finalize(); > > return 0; > } > > the gcc cmd line: > > g++ -o a a.c > -I/usr/local/include/python /usr/local/lib/libpython -lm -lpthread > -ldl > > First problem: > > when i run the a, the error msg is : > > Traceback (most recent call last): > File "<string>", line 1, in ? > File "./a.py", line 1 > SyntaxError: encoding problem: with BOM > > > > but if i first import a.py through the python cmd line. This problem > disappears.(but second problem appears)(now I think the a import > a.pyc not a.py) > > I think it's python bug, isn't it? > > Second problem, > > Traceback (most recent call last): > File "<string>", line 1, in ? > File "a.py", line 3, in ? > import random > File "/usr/local/lib/python2.4/random.py", line 44, in ? > from math import log as _log, exp as _exp, pi as _pi, e as _e > ImportError: /usr/local/lib/python2.4/lib-dynload/math.so: undefined > symbol: PyExc_OverflowError. > > > > Pls give me some advice, i am crazy.thanks > > >
Sorry, but both programs work fine on my system (Mandriva Linux 2006 -2.6.12 kernel, python 2.4.1, gcc 4.0.1). Obviously I had to change a couple of paths to includes and libraries, but apart from that running a.py and the compiled c program worked fine. Perhaps it would help if you told us a bit about your particular configuration. Regards, John -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- http://mail.python.org/mailman/listinfo/python-list