Invoking Python script inside MainComponent with the chance to store its output

Hello everyone.
I have a Python script which is in charge to give me as an output a list of strings after exploiting several Python libraries.

I would like to launch this script inside Juce and store the output inside a variable. I tried to implement my own code by following an old thread (

#include "MainComponent.h"

#ifdef _DEBUG
    #define _DEBUG_WAS_DEFINED
    #undef _DEBUG
#include <Python.h>
    #define _DEBUG


    FILE* pyFile;
    PyRun_SimpleFile(pyFile, pythonFile.getFullPathName().toRawUTF8());

However, the code does not work. I’m trying to follow the instructions written here:, but unfortunately I’m getting nowhere.

Any suggestions?

Brief update:
after adding my lib and include path of Python inside Exporters → Visual Studio Code → Debug and inside Exporters → Visual Studio Code → Release, I’m able to simply declare #include <Python.h>

After several attempts, I’m trying to implement something with the pybind11 library.

#include <pybind11/embed.h>
#include <pybind11/pybind11.h>
namespace py = pybind11;

    auto math = py::module::import("math");
    auto resultobj = math.attr("sqrt")(2);
    double result = resultobj.cast<double>();

However, I get the following error:

_PyRuntime.gc.**generation0** was nullptr.

Did you ever get anywhere with this? I’m currently trying the same thing without any luck.