Exception: Environment not properly prepared. in /var/www/Nextcloud/nextcloud/lib/private/Console/Application.php:166

Hi everyone,
I’m trying to upgrade my NC from 15 to 16 but I’m getting some troubles. My PHP versions is:

PHP 7.2.29-1+0~20200320.39+debian9~1.gbp513c2e

When I try to execute the command:

pi@raspberrypi:/var/www/Nextcloud/nextcloud $ sudo -u www-data php7.0 ./updater/updater.phar 

Nextcloud Updater - version: v16.0.3-3-ga0c2b25 dirty

Current version is 16.0.9.

Update to Nextcloud 16.0.7 available. (channel: “stable”)
Following file will be downloaded automatically: https://nextcloud.com/outdated-php-7-0/
Open changelog :arrow_upper_right:
The updater is disabled for this update - please update manually.

Steps that will be executed:
[:heavy_check_mark:] Check for expected files
[:heavy_check_mark:] Check for write permissions
[:heavy_check_mark:] Create backup
[:heavy_check_mark:] Downloading
[:heavy_check_mark:] Verify integrity
[:heavy_check_mark:] Extracting
[:heavy_check_mark:] Enable maintenance mode
[:heavy_check_mark:] Replace entry points
[:heavy_check_mark:] Delete old files
[:heavy_check_mark:] Move new files in place
[:heavy_check_mark:] Done

Continue update? [y/N] y

Info: Pressing Ctrl-C will finish the currently running step and then stops the updater.

[:heavy_check_mark:] Check for expected files
[:heavy_check_mark:] Check for write permissions
[:heavy_check_mark:] Create backup
[:heavy_check_mark:] Downloading
[:heavy_check_mark:] Verify integrity
[:heavy_check_mark:] Extracting
[:heavy_check_mark:] Enable maintenance mode
[:heavy_check_mark:] Replace entry points
[:heavy_check_mark:] Delete old files
[:heavy_check_mark:] Move new files in place
[:heavy_check_mark:] Done

Update of code successful.

Should the “occ upgrade” command be executed? [Y/n] y
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
PHP module GD not installed.
Please ask your server administrator to install the module.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/Nextcloud/nextcloud/lib/private/Console/Application.php:166
Stack trace:
#0 /var/www/Nextcloud/nextcloud/console.php(96): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/Nextcloud/nextcloud/occ(11): require_once(’/var/www/Nextcl…’)
#2 {main}
Keep maintenance mode active? [y/N] n
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
PHP module GD not installed.
Please ask your server administrator to install the module.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/Nextcloud/nextcloud/lib/private/Console/Application.php:166
Stack trace:
#0 /var/www/Nextcloud/nextcloud/console.php(96): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/Nextcloud/nextcloud/occ(11): require_once(’/var/www/Nextcl…’)
#2 {main}
Maintenance mode is disabled

What is it wrong?

As printed, install and activate the PHP gd module.