Try ALMA, the state-of-the-art Arabic lemmatizer that outperforms all other tools in both speed and accuracy.
Just copy and paste your Arabic text into the ALMA demo, and you can download the results as a CSV file. Otherwise, you can integrate ALMA into your code using SinaTools.
ALMA Paper: https://www.jarrar.info/publications/JAH24.pdf
ALMA Demo: https://sina.birzeit.edu/alma/
SinaTools Documentation: https://sina.birzeit.edu/sinatools/documentation/api/morphology/morph_analyzer.html