Try to find 'ebook-convert' (from Calibre) and use it if KindleGen is not in current directory.

It gives preference to KindleGen over ebook-convert