A train driver died and at least 40 people were injured in the crash on the single-track line to Machu Picchu.