All Questions
Tagged with python-embedding python-c-api
52 questions
1
vote
1
answer
87
views
Access application data when extending embedded Python
I am writing an application that embeds a Python interpreter. The application also extends Python with a custom module. This is done along the lines of the "Extending and Embedding the Python ...
1
vote
0
answers
464
views
Importing python file to c++ program - ModuleNotFoundError
Following this thread
Assume I have the following files in the directory prog:
main.cpp (located in the directory prog)
int main(int argc, char *argv[]){
Py_Initialize();
//Adding current path
...
0
votes
1
answer
560
views
Embedded Python: fatal error in sub-interpreter with C++ multi-thread when cleanup
I'm trying to use Sub-interpreter for having distinct environment, and having multi-thread on same environment(interpreter).
However, when I tried to cleanup sub-interpreter, Python raise Fatal error ...
0
votes
1
answer
986
views
PyObject_CallMethod: call static member function from c++
I've embedded Python (3.6) code into my C++ application successfully. I use the Python/C API to call methods from this library. An overview of the python module is as follows:
class MyClass(object):
...
1
vote
1
answer
1k
views
PyImport_Import failing when submodules are imported in a python module
I have a cpp code like this:
void callPython() {
Py_Initialize();
PyObject* sysPath = PySys_GetObject("path");
PyList_Append(sysPath, PyUnicode_FromString("/jarvis_repo/src/cpp/...
1
vote
1
answer
2k
views
Embedded Python: Multiple Sub-Interpreters not working
I'm trying to understand sub-interpreters and GIL. But my experiment is failing often(The same code rarely works).
Gathering info from SO questions and few sites, I have the following code which ...
4
votes
1
answer
2k
views
How to interrupt python interpreter embedded in C++ application
We have a C++ QT application, we embedded python in it.
We provided two interfaces to the user
1. Execute file
2. Stop execution.
We execute a python file in a non GUI thread, using ...
0
votes
1
answer
2k
views
Embedding python in c++: Segmentation fault [duplicate]
I am remote Debugging a c++ application with Visual studio on a linux device (raspberry pi/raspbian). In this c++ application I embedded a simple Python script by loading the function using the Python/...
2
votes
1
answer
964
views
Error when Importing tensorflow in embedded python in c++
My question is regarding embedding Python 3.5 interpreter in a C++ program to receive an image from C++, and use it as an input for my trained tensorflow model. When I import tensorflow library in my ...
7
votes
1
answer
3k
views
Embedded python code in c++ - error when importing python libraries
I am trying to use Python 3.5 interpreter embedded in a C++ program to receive an image from C++, and use it as an input for my trained tensorflow model. First, I convert my image to numpy array and ...
2
votes
1
answer
2k
views
Passing two parameters (int and array) to embedded Python function
I need to call Python function from my module and set two parameters for it: int and array.
For a now I get segfault during calling this function and I have no idea what I'm doing wrong. Could ...
6
votes
0
answers
2k
views
Extending and Embedding Python in C++: Is PyImport_AddModule required to import extension module before importing python script?
I am embedding Python in a C++ application and I also need to call back in to the C++ code from Python. I have been able to do this with the following simple example but I'm having a weird problem in ...
1
vote
1
answer
1k
views
C/C++ Python exception traceback not being generated
I recently upgraded a C++ project I'm working on, which embedds python, from Python 3.4.3 to Python 3.5.2 (it is an executable that builds as 32 or 64 bits, and has the same behavior in both versions)....
0
votes
3
answers
2k
views
How can convert PyObject variable to Mat in c++ opencv code
I have a c++ facerecognition code and a python code in opencv. In python code i read frames from a robot and i want to send this fram to my c++ code.
I use this link tho call python function in c++ ...
1
vote
1
answer
858
views
Embedding Python in C: Passing a two dimensional array and retrieving back a list
I want to pass a list of arrays (or a 2D array) such as [[1,2,3],[4,5,6]] from C to a Python script which computes and returns a list. What possible changes would be required to the embedding code in ...