PHP7.4 fails to find imagick module

I found this, which suggests that ImageMagick can be fickle:

It also clarified the difference between TS and NTS versions mentioned in the thread below.

This thread also suggests that finding the correct version of ImageMagick seems to be a solution:

Also paths and dependencies especially come up regularly as a cause, which seems more likely.

Any way to get this reliably resolved as there are a number of threads that have a similar problem?