In the 3D printing process, various error factors can affect the accuracy of the final printing quality. However, current 3D printing error compensation methods have limited effects and usually cannot work in real-time. The 3D printing error compensation process is modeled as a Markov decision process (MDP) in this paper, and Deep Reinforcement Learning (DRL) is applied for dynamic error compensation. This method learns autonomously through trial and error by interacting with the printing environment, which makes it adaptable to various types of 3D printers without specific training. Then, we simulate the digital light processing (DLP) 3D printing. Due to the huge state and action space of sliced images, applying the DRL algorithm to DLP is challenging. We propose an error compensation method based on morphological image operation and use Autoencoder to extract error features to reduce the state space. We then implement our method using a Twin Delayed Deep Deterministic policy gradient algorithm (TD3). The results demonstrate the effects of our method in compensating 3D printing errors.