We recieve this error while trying to edit ContentByQueryWebPart.
The reason for this error is because the publishing features are not enabled for the site.
So we need to enable the publishing features.
For this first activate Office Sharepoint Server Publishing Infrastructure feature found at
Site Collection Administration – Site Collection Features.
Than enable Office Sharepoint Server Publishing feature at Site Administration- Site features