Carbon molecular sieve membranes (CMSM) were prepared from the pyrolysis of polyimide films within a temperature range of 600°C‐800°C under nitrogen stream. The membrane samples were characterized and tested for the permeation of He, CH4, CO2, and N2 at different pressures and temperatures, respectively. The CMSM700 membrane (pyrolyzed at 700°C) showed an ideal selectivity of ~ 11 for N2/CH4 with a permeability of 2.18 × 10−15 mol · m/m2 · s · Pa for N2. The separation mechanism for the N2/CH4 pair was shown to be largely molecular sieving rather than surface flow. The membrane showed an ideal selectivity of ~ 500 for the CO2/CH4 pair with a CO2 permeability of 9.72 × 10−14 mol · m/m2 · s · Pa. The permeability of He was lower than that of CO2, suggesting that the surface flow played a significant role in the CO2 permeation. The updated permeability‐selectivity tradeoff curves show that this CMSM membrane compared favourably with other membrane materials reported in the literature for the removal of N2 and CO2 from CH4 for natural gas upgrading.