 The family moved to St Andrews in 1894 when his father was given a new professorship there.Ritchie was educated at Fettes College, then studied Science at the University of St Andrews and Philosophy at Trinity College, Cambridge.Qualified as a chemist, he served as an official chemist in the Royal Naval Air Service (looking at gas for airships) in World War I.