Yes, we know that popes are not perfect.
The Church openly recognizes that popes are not perfect.
Then-Cardinal Joseph Ratzinger (now Pope Benedict XVI) was asked on Bavarian television in 1997 if the Holy Spirit is responsible for who gets elected Pope. His response was:
“I would not say so, in the sense that the Holy Spirit picks out the Pope. … I would say that the Spirit does not exactly take control of the affair, but rather like a good educator, as it were, leaves us much space, much freedom, without entirely abandoning us. Thus the Spirit’s role should be understood in a much more elastic sense, not that he dictates the candidate for whom one must vote. Probably the only assurance he offers is that the thing cannot be totally ruined. … There are too many contrary instances of popes the Holy Spirit obviously would not have picked!”
There is a common misconception among Protestants that the Catholic doctrine of papal infallibility means, essentially, that popes can never be wrong about anything. However, that is not what the Church teaches. The Pope is only infallible when he is speaking ex cathedra (basically, when he is instructing all of the faithful at once about something relating to faith or morals).
In the First Vatican Council (1869-1870) papal infallibility was defined:
“Therefore, faithfully adhering to the tradition received from the beginning of the Christian faith, to the glory of God our savior, for the exaltation of the Catholic religion and for the salvation of the Christian people, with the approval of the Sacred Council, we teach and define as a divinely revealed dogma that when the Roman Pontiff speaks EX CATHEDRA, that is, when, in the exercise of his office as shepherd and teacher of all Christians, in virtue of his supreme apostolic authority, he defines a doctrine concerning faith or morals to be held by the whole Church, he possesses, by the divine assistance promised to him in blessed Peter, that infallibility which the divine Redeemer willed his Church to enjoy in defining doctrine concerning faith or morals. Therefore, such definitions of the Roman Pontiff are of themselves, and not by the consent of the Church, irreformable.”
(By the way, you can read the documents from the First Vatican Council here.)
Popes are capable of sinning, just like any other person, and they know that. In fact, Popes typically go to Confession fairly often, even though Catholics are only duty-bound (by one of the Precepts of the Church, which you can read about here) to go to Confession at least once a year.
Now, some point to popes such as Pope Alexander VI and others as proof that popes are corrupt and unworthy of their office. However, I do not believe that personal flaws necessarily mean a pope is bad, nor do they prevent a pope from doing good.
For example, Pope Alexander VI helped with negotiations between Spain and Portugal (which eventually led to the Treaty of Tordesillas and what is sometimes called the “Papal Line of Demarcation”) and encouraged the development of education by signing a papal bull which founded King’s College, Aberdeen. He also, after the 1492 expulsion of Jews from Spain, welcomed thousands of Jews into Rome.
If you read more about the what some call “bad popes,” you will see that, underneath a handful of flaws, the vast majority of them were men with many positive attributes who, for one reason or another, felt called to serve God.
But let us look at this from a different perspective. Not all Presidents of the United States are well-liked, but that does not have any bearing on their authority. Even if you may not like the person administering the law, you are still obliged to follow the law.
Popes are not perfect, but that is irrelevant. They are the successors of St. Peter. They have been chosen to lead us, and it is our job to listen to them (on matters of faith and morals, at the very least). After all, the Holy Spirit is more than capable of speaking through them and making sure that we are not led astray.