  Recently the AMS-02 collaboration has published the measurement of the cosmic
antiproton to proton ratio $\bar{p}/p$ and the $\bar{p}$ flux with a high
precision up to $\sim 450\,\mathrm{GeV}$. In this work, we perform a systematic
analysis of the secondary antiproton flux generated by the cosmic ray
interaction with the interstellar gas. The uncertainty of the prediction
originates from the cosmic ray propagation process and the hadronic interaction
models. Although the cosmic ray propagation parameters have been well
controlled by the AMS-02 $B/C$ ratio data for a specified model, different
propagation models can not be discriminated by the $B/C$ data. The $\bar{p}$
flux is also calculated for several hadronic interaction models, which are
generally adopted by the cosmic ray community. However, the results for
different hadronic models do not converge. We find the EPOS LHC model, which
seems to fit the collider data very well, predicts a slightly lower $\bar{p}/p$
ratio than the AMS-02 data at the high energy end. Finally we derive the
constraints on the dark matter annihilation cross section from the AMS-02
$\bar{p}/p$ ratio for different propagation and hadronic interaction models.
