'Trouble importing "kivy.garden.matplotlib.backend_kivyagg import FigureCanvasKivyAgg"

Quick overview of my goals: Trying to create an app that has two rows of buttons with dynamic labels - "Humidity: x" x being the average relative humidity taken from a sensor on an Arduino circuit - one on top and one on the bottom, with a live matplotlib graph of all of the various sensor data from a mushroom grow room. The idea is to automate all the variables - humidity on/off, intake fan on/off, and outtake fan on/off -- via Python, and be able to monitor anywhere from my phone via the Kivy app.

I've been following along to John from Codemy's Kivy playlist and so far everything has worked. I have all of my buttons created (not functional yet... but hey, I learned how to use float.layout, so I'm happy ;)) and now I am looking to add the matplotlib graph - this ideally will be live data that another python script will continue to churn out, but for now I just want to make sure I can get a graph in - but am having issues importing the kivy.garden.matplotlib.backend_kivyagg module.

My code:

#:kivy2.0.0
from kivymd.app import MDApp
from kivy.uix.widget import Widget
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.garden.matplotlib.backend_kivyagg import 
FigureCanvasKivyAgg
import matplotlib.pyplot as plt



class Atmos(MDApp):
     def build(self):
         self.theme_cls.them_style = "Dark"
         self.theme_cls.primary_palette = "BlueGray"
         return Builder.load_file('monitor.kv')

The error I get:

Traceback (most recent call last):
   File "/Users/owenthomas/ATMOS/APP/MONITOR.py", line 7, in 
<module>
     from kivy.garden.matplotlib.backend_kivyagg import 
FigureCanvasKivyAgg
   File "<frozen importlib._bootstrap>", line 1007, in 
_find_and_load
File "<frozen importlib._bootstrap>", line 986, in 
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 635, in 
_load_backward_compatible
KeyError: 'kivy.garden.matplotlib'`

I believe I have installed everything I need:

enter image description here

I am using a venv running python 3.9.12, on Mac OS, if that makes a difference.

This is the second attempt at creating the venv to house all the modules, I am going to try a third time as well, however.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source