Error in Python Embeded in Qt C++


 
Thread Tools Search this Thread
Top Forums Programming Error in Python Embeded in Qt C++
# 1  
Old 10-03-2010
Error in Python Embeded in Qt C++

hi
i have an error in script language when run it
i use python 2.4, CentOS 5.5, Qt C++ 2010/04
the error is
SystemError: null argument to internal routine
the Python Code
Code:
def main(i):
    print i
 
if __name__ == "__main__":
    main(i)

the C++ Code
Code:
            PyObject *objModule = NULL;
            PyObject *objDict = NULL;
            PyObject *objExpression = NULL;
            PyObject *objArgs = NULL;
            objModule = PyImport_AddModule((char*)"__main__");
            //pValue = PyInt_FromLong(atoi(cKeyNum));
            //objArgs = PyTuple_New(1);
            //PyTuple_SetItem(objArgs, 0, pValue);
            objArgs = Py_BuildValue("(i)", cKeyNum);
            Py_IncRef(objModule);
            objDict = PyModule_GetDict(objModule);
            objExpression = PyDict_GetItemString(objDict, "main");

            //PyCodeObject *objCode = (PyCodeObject *)PyFunction_GetCode(objExpression);
            //PyEval_EvalCodeEx(objCode, objDict, NULL, objArgs, 0, NULL, 0, NULL, 0, NULL);

            //pValue = PyObject_CallObject(objExpression, objArgs);
            PyObject_CallFunction(objExpression, "[i]", cKeyNum);

please help me to fix it
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Tuple Error in Python

Hi, I am getting the below error: AttributeError: 'tuple' object has no attribute 'field_id' This line is complaining on the below code snippet: field_list = for f in source_rows: field_list.append(f.field_id) Where source_rows returns multiple rows of... (1 Reply)
Discussion started by: ChicagoBlues
1 Replies

2. Shell Programming and Scripting

Python Name Error

Hi There, I have the following code: import time import paramiko node_list = for node in node_list: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(node, username='lord', password='xxxx') variables = {} stdin,... (3 Replies)
Discussion started by: infinitydon
3 Replies

3. Shell Programming and Scripting

Embeded shell variable in command line

Hello, I know this is a situation about the single quote and double literal, but I could not figure out after many search. I need to loop through thousands of different BACs sequencing to optimize kmer individually. IN=/PATH/TO/INPUT/FILES for sample in S{01..1096} do run_program... (9 Replies)
Discussion started by: yifangt
9 Replies

4. Shell Programming and Scripting

python - string encoding error

I'm trying to pull a google calendar (successful) and then put the contents into a mysql db (almost successful). On one of the field I keep getting an encode error: #!/usr/bin/python from xml.etree import ElementTree import gdata.calendar.data import gdata.calendar.client import... (12 Replies)
Discussion started by: unclecameron
12 Replies

5. Shell Programming and Scripting

python script error

Hi I have written a script in python and used it inside Ubuntu and its worked for me. The script import email.utils, however in centos when I try to run the script I get: Traceback (most recent call last): File "./warning.py", line 4, in ? import email.utils ImportError: No... (2 Replies)
Discussion started by: programAngel
2 Replies

6. Programming

Python MySQL error

Hey all, I'm trying to enter some data into a database and I keep getting this error: Traceback (most recent call last): File "./ais_file_parser.py", line 77, in <module> cursor.execute(sql) File "/usr/lib/pymodules/python2.7/MySQLdb/cursors.py", line 166, in execute ... (1 Reply)
Discussion started by: pmd006
1 Replies

7. Shell Programming and Scripting

problem in embeded command substitution

$ echo $(tty|sed 's#/*/##') pts/0 $ who | grep $(tty|sed 's#/*/##') grep: 0652-033 Cannot open 0551-011. grep: 0652-033 Cannot open Standard. grep: 0652-033 Cannot open input. grep: 0652-033 Cannot open is. grep: 0652-033 Cannot open not. grep: 0652-033 Cannot open a. grep: 0652-033 Cannot... (2 Replies)
Discussion started by: wrl
2 Replies

8. Shell Programming and Scripting

Define an alias with an embeded awk command ??

Hi all, I'm trying to define an alias with an embeded awk command: alias kpipe='kill `psme| grep "ifw -r" | grep -v "grep ifw -r"| awk '{print $2}'`' The problem is that the awk command (awk '{print $2}') contains two ' ..' quotes. So bash assumes that the first awk quote corresponds to... (5 Replies)
Discussion started by: jfortes
5 Replies

9. Shell Programming and Scripting

AWK embeded PERL

Hello Guys, I am refering to this great forum once again for help. After various attempts at this, I am still failing to obtain the desire effect. I have to write a perl script which: 1- reads two values from the user (e.g name & passwd) 2- check each value against a file containing the... (7 Replies)
Discussion started by: bionicfysh
7 Replies
Login or Register to Ask a Question