You can get this error message even if Craft installation is OK. If you work in MAMP environment and have this error message, check if your PHP and MySQL are available from command line (Terminal).
To check PHP, do following:
Open terminal and type: $ which php
If you see something like "/usr/bin/php" that means MAMP's PHP is not available from command line.
We have to modify the $PATH variable modifying the file ~/.bash_profile located in your root user folder.
Type: $ sudo nano ~/.bash_profile
Edit PATH by entering path to MySQL and PHP (pay attention on php version that you have in your MAMP)
PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php7.3.9/bin:$PATH
Save changes and reload edited .bash_profile with:
$ source ~/.bash_profile
Check PHP with:
$ which php
If you see "/Applications/MAMP/bin/php/php7.3.9/bin/php" this is it ;)