The invention provides a method for preparing a compound shown as the formula I (please see the formula in the description). The method specifically comprises the following steps that 1, a compound shown as the formula (II) (please see the formula in the description) reacts with a compound shown as formula (V) (please see the formula in the description) under the alkaline condition to generate a compound shown as the formula (III) (please see the formula in the description); 2, the compound shown as the formula (III) (please see the formula in the description) reacts with a compound shown as the formula (VI) (please see the formula in the description) under the alkaline condition in the presence of palladium carbon to generate a compound shown as the formula (IV) (please see the formula in the description); 3, the compound shown as the formula (IV) (please see the formula in the description) reacts in the presence of palladium carbon and a hydrogen source under the alkaline condition to generate the compound shown as the formula (I) (please see the formula in the description). According to the method, design is ingenious, protecting group removal, dechlorination and nitro reduction are together completed in the final hydrogenation process, and the purity of the obtained compound shown as the formula (I) (please see the formula in the description) is high; the most important thing is that compared with other Suzuki coupling agents, cost of palladium carbon is lower, a source of palladium carbon is wide and easy to obtain, palladium carbon can be directly recycled and reused after being simply filtered and separated, and therefore the material cost is greatly reduced; meanwhile, emission of three wastes is reduced, and the method is quite suitable for industrialized production.