Trying to call python functions from my GUI, compiler is out of heap space
-
wrote on 24 Aug 2021, 19:56 last edited by lfreeman6490
I am attempting to call functions from a python script in my and I have included pybind11 to try to help me do this. Once I include this I get the error
C1060: compiler is out of heap space
that's without any code or anything like that. I'm aware that this error usually comes when uploading libraries or external files that are massive. The only imports I have are for pybind11, and python.h.
So I guess I have two questions. My first one, is there a work around for this or how can I fix this?
My second question, if not, is there a better way to call a python function? What I want is to have a connect button in my GUI and then once that button is clicked, it calls a python function in my .py file.
-
Hi,
Why are you including both since you want to use pybind11 ?
-
wrote on 24 Aug 2021, 20:17 last edited by lfreeman6490
@SGaist I was told I needed both. Getting rid of the 'python.h' import and leaving in the 'pybind11' import does not get rid of the error. Getting rid of pybind11 but leaving in python.h does get rid of the error
-
Which compiler are you using ?
On which platform ? -
wrote on 25 Aug 2021, 13:30 last edited by
@SGaist I'm using QTCreator v3.0.1
c++ GUI
windows 10
32bit python 2.7 -
@SGaist I'm using QTCreator v3.0.1
c++ GUI
windows 10
32bit python 2.7Hi and which compiler mingw or visual studio ?
-
Hi and which compiler mingw or visual studio ?
wrote on 25 Aug 2021, 14:04 last edited by@mrjj mingw
-
@mrjj mingw
@lfreeman6490
Hi
Im not sure if that is supported.
https://github.com/pybind/pybind11Its not listed in compilers.
Also is this 32 bit mingw ?
or 64 ? -
@lfreeman6490
Hi
Im not sure if that is supported.
https://github.com/pybind/pybind11Its not listed in compilers.
Also is this 32 bit mingw ?
or 64 ?wrote on 25 Aug 2021, 14:10 last edited by@mrjj It's 32 bit, I used pip to install it. If it is not supported are you aware of another way that I can call python functions?
-
@mrjj It's 32 bit, I used pip to install it. If it is not supported are you aware of another way that I can call python functions?
From link
3, Microsoft Visual Studio 2015 Update 3 or newerIt does support visual studio 2015 it seems so that might work with 32 bit.
So you could install vs 2015 compiler if that can work with your app ?
-
From link
3, Microsoft Visual Studio 2015 Update 3 or newerIt does support visual studio 2015 it seems so that might work with 32 bit.
So you could install vs 2015 compiler if that can work with your app ?
wrote on 25 Aug 2021, 15:13 last edited by lfreeman6490@mrjj I've been headed this direction and I ditched pybind11, I have been able to get my python file to compile, but not much after that. My file is "test_py_file" and my function is "test_function". There are no errors being thrown at the moment, but also it is not executing the function.
void f_pathloss::on_pb_tester_connect_disconnect_clicked() { PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *presult; Py_Initialize(); pName = PyString_FromString((char*)"test_py_file"); pModule = PyImport_Import(pName); pDict = PyModule_GetDict(pModule); pFunc = PyDict_GetItemString(pDict, (char*)"test_function"); Py_Finalize(); }
-
@mrjj I've been headed this direction and I ditched pybind11, I have been able to get my python file to compile, but not much after that. My file is "test_py_file" and my function is "test_function". There are no errors being thrown at the moment, but also it is not executing the function.
void f_pathloss::on_pb_tester_connect_disconnect_clicked() { PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *presult; Py_Initialize(); pName = PyString_FromString((char*)"test_py_file"); pModule = PyImport_Import(pName); pDict = PyModule_GetDict(pModule); pFunc = PyDict_GetItemString(pDict, (char*)"test_function"); Py_Finalize(); }
wrote on 25 Aug 2021, 15:52 last edited by JonB@lfreeman6490
You pasted this code elsewhere with the same comment. How do you/we know it is doing nothing? And I asked you whether you really havetest_py_file
andtest_function
in it, else what do you expect?And I also suggested you try a different example @mrjj had quoted you.
It helps if we keep the same question in one thread....
-
Hi
There is something missingpFunc = PyDict_GetItemString(pDict, (char*)"test_function");
this gets you a function pointer but you do not call it.
something like
PyObject* myResult = PyObject_CallObject(pFunc , args)args can be NULL if none is needed
-
Hi
There is something missingpFunc = PyDict_GetItemString(pDict, (char*)"test_function");
this gets you a function pointer but you do not call it.
something like
PyObject* myResult = PyObject_CallObject(pFunc , args)args can be NULL if none is needed
wrote on 26 Aug 2021, 17:59 last edited by@mrjj I decided to use pybind11, I'm still fighting off errors this way but it seems better. Thank you for the suggestions
-
@mrjj I decided to use pybind11, I'm still fighting off errors this way but it seems better. Thank you for the suggestions
Hi
Well pybind11 is harder to get going but will be much nicer code-wise than the PyObject_xxxx interface for a more
complete integration but If you only need to call one function in python, pyBind11 might be a little overkill but
is then very future proof. -
Hi
Well pybind11 is harder to get going but will be much nicer code-wise than the PyObject_xxxx interface for a more
complete integration but If you only need to call one function in python, pyBind11 might be a little overkill but
is then very future proof.wrote on 26 Aug 2021, 20:36 last edited by@mrjj yeah I've been struggling with pybind11 a ton so far. Haven't gotten much of anywhere really. But I am going to need to use a decent amount of functions from the Python file
-
@mrjj yeah I've been struggling with pybind11 a ton so far. Haven't gotten much of anywhere really. But I am going to need to use a decent amount of functions from the Python file
Hi
What kind of errors ?make sure to read the docs as its a bit hysteric with the compilers
https://pybind11.readthedocs.io/en/stable/basics.htmlThe PyObject_CallObject API didnt work for you or why did you give it up so fast ?
1/17