Rocks thrown from an overpass in Sydney's west have smashed through a train window and injured the driver.

Police said the rocks were believed to have been thrown from the overpass near Rooty Hill station.

The train stopped at Penrith station, where the 42-year-old St Clair man was treated by paramedics before being taken to Nepean Hospital.

His injuries are not considered serious and no one else was injured.

Police have appealed for witnesses to come forward.

AAP