1

I am using RFID reader module (MFRC522) with my raspberry pi and when I run the script with python 2 it works fine and reads the RFID tag but when I run it with python3 I get an error - No Module named 'spi'

My script is -

import RPi.GPIO as GPIO
import SimpleMFRC522
reader = SimpleMFRC522.SimpleMFRC522()
try:
        id,text = reader.read()
        print(text)
finally:
        GPIO.cleanup()

I need this to run with python3 because I am using Firebase in my project and it works with python3, not python2.7

  • have you tried installing SPI? pip3 install spi? – Jaromanda X Apr 2 at 7:49
  • Or you forgot the statement "import spidev". – tlfong01 Apr 2 at 8:03
1

Turns out that the official package for the MFRC522 module was written in python2 and hence causing the issue. I found an updated package by a user on github and it works fine now. Github Link to the package

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.