LaTeX stopped working and a nonsense error message is issued

I have a system with Windows 11, Python 3.10.8 and Matplotlib 3.9.2 and MiKTeX 24.0. Until a couple of weeks ago, I was able to plot nice charts like this one:

But not any more. Out of the blue, with no updates or upgrades, LaTeX stopped working. Now I get a strange error that seems to have nothing to do with a Windows system (after a lot of omitted lines):

FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/texmf-dist/fonts/tfm/public/cm/cmr10.tfm'

In this case, I was trying to use the Computer Modern Roman font.

The point is: this is a Windows system, while “/usr/share/texmf-dist/fonts/…” is clearly a Linux path. How are those things related?

May I ask, therefore:

(1) Where from does Matplotlib fetch the TeX-style fonts? As I said, I have MiKTeX installed.
(2) Is there a command that can tell me what is Matplotlib trying to do?
(3) Could I change the Matplotlib configuration file to point to the TeX fonts?

Yet, a simple script like this (without TeX) one works nicely:

from matplotlib import pyplot as plt
import numpy as np

x = np.linspace(-2.0*np.pi, 2.0*np.pi, 200)

plt.figure(1)
plt.xlabel("x")
plt.ylabel("f(x)")
plt.plot(x, np.cos(x), 'b.')
plt.show()

it’s only when I try to use TeX rendering that I get that error message and a blank plotting window.

Any help will be much appreciated. I really don’t know what to do. I have uninstalled and reinstalled everything more than once - to no avail.

Thanks.

Please provide the entire error.

Please provide the entire code