We study electronic properties of single-walled carbon nanotubes (SWNTs) upon gas molecules adsorption with first principles methods. The adsorption energy, charge transfer, and electronic structures are studied for various gas molecules (NO2, O2, NH3, N2, CO2, CO, H2O, H2, He). Most molecules adsorb weakly on SWNTs and can be either charge donor or accepter to the nanotubes. The electronic properties of nanotubes are sensitive to the adsorption of certain molecules such as NO2 and O2. Charge transfer and gas-induced charge fluctuations are found to significantly affect the transport properties of SWNTs. Our results are consistent with recent experiments.