After verifying the Makefile, I was able to pinpoint the issue. Line 17, shown below, retrieves a list of site packages and picks the first one. NUMPY_FLAGS := $(shell python3 -c "import site; print(site.getsitepackages()[0])")
Running the command python3 -c "import site; print(site.getsitepackages()[0])" returns the following: ['/usr/local/lib/python3.12/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.12/dist-packages']
However, in my WSL Ubuntu installation, there is no directory “dist-packages” under python3.12. That directory is under python3 and that’s what causes the error, as it tries to include “-I/usr/local/lib/python3.12/dist-packages/numpy/core/include”.
The solution was to edit the Makefile and change line 17 to NUMPY_FLAGS := $(shell python3 -c "import site; print(site.getsitepackages()[1])") so it would pick the second item on the list, '/usr/lib/python3/dist-packages', thus preventing the error from happening.