In this paper we study the widely considered endomorphisms and weak endomorphisms of a finite undirected path from monoid generators perspective. Our main aim is to determine the ranks of the monoids $wEnd P_n$ and $End P_n$ of all weak endomorphisms and all endomorphisms of the undirected path $P_n$ with $n$ vertices. We also consider strong and strong weak endomorphisms of $P_n$.