Papal Infallibility comes from the bible:
>Matthew 16:18-19
"I will give you the keys of the kingdom of heaven; whatever you bind on earth will be bound in heaven, and whatever you loose on earth will be loosed in heaven.”
>Luke 22:29-32
And I confer on you a kingdom, just as my Father conferred one on me, so that you may eat and drink at my table in my kingdom and sit on thrones, judging the twelve tribes of Israel.
“Simon, Simon, Satan has asked to sift all of you as wheat. But I have prayed for you, Simon, that your faith may not fail. And when you have turned back, strengthen your brothers.”
>John 21:15-17
When they had finished eating, Jesus said to Simon Peter, “Simon son of John, do you love me more than these?”
“Yes, Lord,” he said, “you know that I love you.”
Jesus said, “Feed my lambs.”
Again Jesus said, “Simon son of John, do you love me?”
He answered, “Yes, Lord, you know that I love you.”
Jesus said, “Take care of my sheep.”
The third time he said to him, “Simon son of John, do you love me?”
Peter was hurt because Jesus asked him the third time, “Do you love me?” He said, “Lord, you know all things; you know that I love you.”
Jesus said, “Feed my sheep."
Papal infallibility is implied. The Pope cannot be wrong when Ex Cathedra because Jesus gave him the power to loose and bind.
As I explained this is impossible because of Papal Infallibility of Pius XII who determined the succession of Popes.