Can a Pope teach an objective heresy or other grave error, inculpably, by ignorance, and without any deliberate knowing fault? In such a case, he would not be guilty of formal heresy, but his teaching would be either material heresy, or a grave error short of heresy.
No, he cannot. For the Pope is preserved from heresy and all grave error, in both his teachings and his decisions on discipline, for the sake of the Church, for the sake of his flock, and not for his own sake. Thus, the Pope is not preserved by grace from most actual mortal sins (other than grave sins against faith or any sin that would harm the indefectibility of the Church). But he is preserved from teaching grave error, even when that act would not be a culpable sin for him.
If Popes and Councils could err gravely, we would have no way of knowing which teachings to believe, so as to judge that a Pope or Council has erred.
Can a Pope commit heresy secretly, which is never expressed? No, for he has the gift of never failing faith given by prevenient grace to his person, not only to his office (though the teachings of the papal office are also protected).