[1.7.x] Avoided using deprecated version of importlib; refs #23418.

Backport of fbeb7979ee from master