Because of that is why you are needing to install all the matplotlib build dependencies when trying to install basemap, since matplotlib also needs to be built from source for this old Python version.
I am running basemap version 1.3.4 Matplotlib 3.8 CentOS 7.8 Using conda. Python 3.10.2 I got this error. cs = m.contourf(x,y,pot ...