When tested by the Extension Service at Mississippi State University, mothballs failed to repel snakes, and no chemical repellent was effective at all.
According to the U.S. Environmental Protection Agency, moth balls contain the dangerous chemical napthelene. The EPA classifies napthalene as a possible human carcinogen. It is also associated with birth defects when pregnant mothers are exposed to it.
The best way to repel snakes is to make sure that you are not providing them a snake friendly habitat. Do not stack any material close to your house that snakes could hide in, and repair any holes in cement or the foundation of your house.
Another effective means of controlling snakes is to bury sheet metal or hardware cloth 6 inches below the surface around the foundation of houses and storage sheds.
While keeping snakes out of the house is important, remember that snakes play a beneficial role in the environment. Snakes eat rats and mice, and many non-venomous snakes eat venomous snakes.