The invention discloses a method for preparing nevirapine, which comprises the steps of: A. enabling 2-chlorine-3 picolinic acid shown in the structural formula (II) and carbonyl diimidazole to react to produce active amide; B. enabling the active amide produced in the step A to react with 2, 6- dichloro-3-amino-4-methylpyridine shown in the structural formula (I), and producing N-(2, 6-dichloro-4-methyl-3-pyridyl)-2-chlorine niacinamide; C. carrying out nucleophilic substitution reaction on the N-(2, 6-dichloro-4-methyl-3-pyridyl)-2-chlorine niacinamide obtained in the step B and cyclopropylamine, then carrying out cyclization on the obtained products to obtain 2-chloro nevirapine with structure shown in the formula (III); and D. under the presence of catalyst, carrying out hydrogenationreaction on the 2-chloro nevirapine with structure shown in the formula (III) in the step C and non-hydrogen hydrogen source, to obtain the nevirapine with structure shown in the formula (IV). The invention aims at providing a method for preparing the nevirapine, which is low in cost, environment-friendly, higher in safety and suitable for production.