Many people have asked me if only Cardinals can be elected Pope. I came across the following in my recent re-reading of the document regulating Papal Elections Universi Dominici Gregis:
83. With the same insistence shown by my Predecessors, I earnestly exhort the Cardinal electors not to allow themselves to be guided, in choosing the Pope, by friendship or aversion, or to be influenced by favour or personal relationships towards anyone, or to be constrained by the interference of persons in authority or by pressure groups, by the suggestions of the mass media, or by force, fear or the pursuit of popularity. Rather, having before their eyes solely the glory of God and the good of the Church, and having prayed for divine assistance, they shall give their vote to the person, even outside the College of Cardinals, who in their judgment is most suited to govern the universal Church in a fruitful and beneficial way.
However the one elected must be capable of being ordained as the bishop of Rome:
Can. 332 §1. The Roman Pontiff obtains full and supreme power in the Church by his acceptance of legitimate election together with episcopal consecration. Therefore, a person elected to the supreme pontificate who is marked with episcopal character obtains this power from the moment of acceptance. If the person elected lacks episcopal character, however, he is to be ordained a bishop immediately.