Pneumocystis pneumonia affects immunocompromised hosts. The typical imaging finding is bilateral diffuse ground glass opacities. Here we presented a case of Pneumocystis causing biopsy-confirmed cavitary lung lesions in a patient with a predominant B cell defect with common variable immune deficiency.