Try to find 'ebook-convert' (from Calibre) and use it if KindleGen is no...

...t in current directory.

It gives preference to KindleGen over ebook-convert