The invention provides a mechanical shafting rotary error active compensation device based on a piezoelectric actuator, and relates to the field of mechanical shafting rotary error active compensation. The device aims at solving the problems that the rotary precision of a traditional rolling bearing supporting shafting can hardly be improved in a breakthrough manner through machining and assembling links. The device comprises a metal end cap, two metal gaskets, the piezoelectric actuator and a base support. The piezoelectric actuator is formed by stacking multiple layers of piezoelectric ceramic pieces and metal electrode pieces, wherein the piezoelectric ceramic pieces and the metal electrode pieces are alternately arranged. Each layer of piezoelectric ceramic piece is composed of four sector rings defining a ring, and a certain gap is reserved between every two adjacent sector rings. In each layer of piezoelectric ceramic piece, the polarization directions of a pair of opposite sector rings are opposite, and the polarization directions of the sector rings corresponding to the adjacent piezoelectric ceramic pieces in the axial direction are opposite, in other words, the polarization directions in the axial direction are alternately distributed. The piezoelectric actuator is used as an actuator of the compensation device, and the beneficial effects of being high in displacementcontrol precision and high in response speed are achieved.