Answer
The Pope who excommunicated Louis IV was Pope John XXII. This occurred during the conflict known as the Investiture Controversy, where Holy Roman Emperors and Popes clashed over the right to appoint bishops. Pope John XXII saw Louis IV's coronation as illegitimate, as it was not sanctioned by the Papacy. The excommunication was an attempt to delegitimize Louis' rule and exert the Pope's authority over secular matters.