You can use the proposed method of McKee et al. (1993) (McKee, Thomas B, Nolan J Doesken, and John Kleist. (1993) the Relationship of Drought Frequency and Duration to Time Scales. In Proceedings of the 8th Conference on Applied Climatology, 17, 179-183: American Meteorological Society Boston, MA, USA.)
The SCI package of R language most used for SPI calculation
Firstly you calculate average value from rainfall data (year wise) then use R studio. If have no SPEI packages in R studio you can install this.Using R studio calculate SPI value is very easy.