Accurate fault diagnosis of complex energy systems, such as wind turbines, is essential to avoid catastrophic accidents and ensure a stable power source. However, accurate fault diagnoses under dynamic operating conditions and various failure mechanisms are major challenges for wind turbines nowadays. Here we present a CapsNet-based deep learning scheme for data-driven fault diagnosis used in a digital twin of a wind turbine gearbox. The CapsNet model can extract the multi-dimensional features and rich spatial information from the gearbox monitoring data by an artificial neural network named the CapsNet. Through the dynamic routing algorithm between capsules, the network structure and parameters of the CapsNet model can be adjusted effectively to realize an accurate and robust classification of the operational conditions of a wind turbine gearbox, including front box stuck (single fault) and high-speed shaft bearing damage & planetary gear damage (coupling faults). Two gearbox datasets are used to verify the performance of the CapsNet model. The experimental results show that the accuracy of this proposed method is up to 98%, which proves the accuracy of CapsNet model in the case study when this model performed three-state classification (health, stuck, and coupled damage). Compared with state-of-the-art fault diagnosis methods reported in the literature, the CapsNet model has a competitive advantage, especially in the ability to diagnose coupling faults, high-speed shaft bearing damage & planetary gear damage in our case study. CapsNet has at least 2.4 percentage points higher than any other measure in our experiment. In addition, the proposed method can automatically extract features from the original monitoring data, and do not rely on expert experience or signal processing related knowledge, which provides a new avenue for constructing an accurate and efficient digital twin of wind turbine gearboxes.