I am trying to read an image using plt.imread() in embedded Python code within my DATA function. The code is as follows:
IMPORT PYTHON3 AS PYTHON;
IMPORT Std;
IMPORT Image;
myRec := RECORD
STRING id;
DATA image;
END;
ds := DATASET('img.flat', myRec, THOR);
dims := GetImageDimensions(ds[2].image);
DATA ReadImage(DATA image, SET OF INTEGER dims) := EMBED(Python)
import cv2
import numpy as np
import matplotlib.pyplot as plt
image_np = np.frombuffer(image, dtype='uint8')
dims = tuple(dims)
image = plt.imread(io.BytesIO(image_np))
print(type(image))
np_array = np.array(image)
print(np_array.shape)
print(np_array)
return bytearray(image_np)
ENDEMBED;
OUTPUT(ReadImage(ds[2].image,dims));
However, I am getting the following error: Error, eclagent, 0, System error: 0: Graph graph1[1], remoteresult[4]: pyembed: No module named 'matplotlib', Master exception - caused by (0, pyembed: No module named 'matplotlib')
I have already installed the matplotlib module using pip install matplotlib==3.7.1
and checked that it is installed in my system. How can I resolve this error and use plt.imread() successfully within my embedded Python code?