#/usr/local/bin/python
import random
print random.randint(0,10)
#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
-- http://mail.python.org/mailman/listinfo/python-list