We studied various gas molecules (NO$_2$, O$_2$, NH$_3$, N$_2$, CO$_2$, CH$_4$, H$_2$O, H$_2$, Ar) on single-walled carbon nanotubes (SWNTs) and bundles using first principles methods. The equilibrium position, adsorption energy, charge transfer, and electronic band structures are obtained for different kinds of SWNTs. Most molecules adsorb weakly on SWNTs and can be either charge donor or acceptor to the nanotubes. We find the gas adsorption on the bundle interstitial and groove sties is stronger than that on an individual tube. The electronic properties of SWNTs are sensitive to the adsorption of certain gases such as NO$_2$ and O$_2$. Charge transfer and gas-induced charge fluctuation might significantly affect the transport properties of SWNTs. Our theoretical results are consistent with recent experiments.