Reading memory through a Python script invoked by JUCE

Hello JUCE Community.
I wrote a Python script which has the task to read a CSV file, to process it and to return a list to the main JUCE program.

Unfortunately, I noticed that the PyObject* pValue that stores the result returns always Null.

After several debugs, I discovered the reason: when I try to access some file in the disk through this Python script (i.e.: df = pd.read_excel('data.xlsx', index_col=False)), the program stops.

Any suggestion on how to manage this situation?

This is the function that, in JUCE (C++), calls the Python script:

#pragma once
#include <Windows.h>
#include <iostream>
#include <JuceHeader.h>
#include <Python.h>
void myFunction()
{
    
    Py_Initialize();

    PyRun_SimpleString("import pandas as pd");
    PyRun_SimpleString("from datetime import date");
    PyRun_SimpleString("import time");
    PyRun_SimpleString("import requests");
    PyRun_SimpleString("import json");
    PyRun_SimpleString("from astroquery.mast import Observations");
    PyRun_SimpleString("from astropy.coordinates import EarthLocation, AltAz, SkyCoord");
    PyRun_SimpleString("import astropy.units as u");

    PyObject* pyName = PyUnicode_FromString("hello");
    PyObject* pyModule = PyImport_Import(pyName);

    if (pyModule != NULL)
    {
        PyObject* pyDict = PyModule_GetDict(pyModule);

        PyObject* pyClass = PyDict_GetItemString(pyDict, "Hello");

        if (PyCallable_Check(pyClass)) {
            PyObject* pyInstance = PyObject_CallObject(pyClass, NULL);

            PyObject* pValue = PyObject_CallMethod(pyInstance, "print_hello", NULL);

            if (pValue == NULL)
            {
                DBG("ERROR");
            }
            else
            {
                auto result = _PyUnicode_AsString(pValue);
                DBG(result);
            }
        }
    }

    Py_Finalize();
}

My Python Script is formatted as it follows:

from datetime import date 
import time
import requests
from astroquery.mast import Observations
from astropy.coordinates import EarthLocation, AltAz, SkyCoord
import astropy.units as u
import pandas as pd
import os
import json

class Hello:
    def __init__(self):
        pass
    def print_hello(self):
        # Do stuff...#
        return "hello"

Any read/write operation inside the Python script (i.e.: df = pd.read_excel('data.xlsx', index_col=False) ) returns NULL as result in the pValue pointer

Any help? :frowning_face: