Problems installing MicroPython Package mfrc522

217 Views Asked by At

I purchased a 37 Raspberry Pi Pico sensor package from a company called Keyestone. In it is a RFID sensor that requires the mfrc522 package. Using Thonny I tried to install the mfrc522 package. When I try to download it, Using the "Tools/Manage Packages", Thonny initially tells me that the package doesn't look like a MicroPython package. I have successfully installed another package even though I initially got the same error. So, I went ahead and tried to install the mfrc522 package and get the error below. I'm working with a Raspberry Pi Pico W. I reinstalled Thonny but that didn't help.

Is there some other package that I should be using?

Thank you for your help.

Tom

Installing to temp directory
"C:\Program Files (x86)\Thonny\python.exe" -m thonny.plugins.micropython.minipip install --target C:\Users\Tom\AppData\Local\Temp\tmph6nwm3cx mfrc522
Processing 'mfrc522'
Querying package metadata from https://micropython.org/pi/mfrc522/json
Could not find 'mfrc522' from https://micropython.org/pi
Querying package metadata from https://pypi.org/pypi/mfrc522/json
Inspecting version 0.0.7
'mfrc522' will be installed with pip (not having single tar.gz asset).
Installing with pip: ['mfrc522']
Collecting mfrc522
  Using cached mfrc522-0.0.7-py3-none-any.whl (18 kB)
Collecting spidev
  Using cached spidev-3.6.tar.gz (11 kB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Collecting RPi.GPIO
  Using cached RPi.GPIO-0.7.1.tar.gz (29 kB)
Building wheels for collected packages: spidev, RPi.GPIO
  Building wheel for spidev (PEP 517): started
  Building wheel for spidev (PEP 517): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: 'C:\Program Files (x86)\Thonny\python.exe' 'C:\Program Files (x86)\Thonny\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\Tom\AppData\Local\Temp\tmpjow6fobs'
       cwd: C:\Users\Tom\AppData\Local\Temp\pip-install-wge7a33p\spidev
  Complete output (26 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'spidev' extension
  creating build
  creating build\temp.win32-cpython-37
  creating build\temp.win32-cpython-37\Release
  "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX86\x86\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD "-IC:\Program Files (x86)\Thonny\include" "-IC:\Program Files (x86)\Thonny\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" /Tcspidev_module.c /Fobuild\temp.win32-cpython-37\Release\spidev_module.obj
  spidev_module.c
  spidev_module.c(33): fatal error C1083: Cannot open include file: 'linux/spi/spidev.h': No such file or directory
  C:\Users\Tom\AppData\Local\Temp\pip-build-env-c4ylp66q\overlay\Lib\site-packages\setuptools\dist.py:755: SetuptoolsDeprecationWarning: Invalid dash-separated options
  !!
  
          ********************************************************************************
          Usage of dash-separated 'description-file' will not be supported in future
          versions. Please use the underscore name 'description_file' instead.
  
          By 2023-Sep-26, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.
  
          See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
          ********************************************************************************
  
  !!
    opt = self.warn_dash_deprecation(opt, section)
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x86\\cl.exe' failed with exit code 2
  ----------------------------------------
  ERROR: Failed building wheel for spidev
  Building wheel for RPi.GPIO (setup.py): started
  Building wheel for RPi.GPIO (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: 'C:\Program Files (x86)\Thonny\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Tom\\AppData\\Local\\Temp\\pip-install-wge7a33p\\RPi.GPIO\\setup.py'"'"'; __file__='"'"'C:\\Users\\Tom\\AppData\\Local\\Temp\\pip-install-wge7a33p\\RPi.GPIO\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Tom\AppData\Local\Temp\pip-wheel-zoqbqqcq'
       cwd: C:\Users\Tom\AppData\Local\Temp\pip-install-wge7a33p\RPi.GPIO\
  Complete output (24 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.7
  creating build\lib.win32-3.7\RPi
  copying RPi\__init__.py -> build\lib.win32-3.7\RPi
  creating build\lib.win32-3.7\RPi\GPIO
  copying RPi\GPIO\__init__.py -> build\lib.win32-3.7\RPi\GPIO
  running build_ext
  building 'RPi._GPIO' extension
  creating build\temp.win32-3.7
  creating build\temp.win32-3.7\Release
  creating build\temp.win32-3.7\Release\source
  C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files (x86)\Thonny\include" "-IC:\Program Files (x86)\Thonny\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" /Tcsource/py_gpio.c /Fobuild\temp.win32-3.7\Release\source/py_gpio.obj
  py_gpio.c
  source/py_gpio.c(87): error C2143: syntax error: missing ';' before '{'
  source/py_gpio.c(200): error C2143: syntax error: missing ';' before '{'
  source/py_gpio.c(227): warning C4047: 'return': 'PyObject *' differs in levels of indirection from 'int'
  source/py_gpio.c(345): error C2373: 'output': redefinition; different type modifiers
  C:\Users\Tom\AppData\Local\Temp\pip-install-wge7a33p\RPi.GPIO\source\constants.h(29): note: see declaration of 'output'
  source/py_gpio.c(345): error C2143: syntax error: missing ';' before '{'
  source/py_gpio.c(359): warning C4047: 'return': 'PyObject *' differs in levels of indirection from 'int'
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for RPi.GPIO
  Running setup.py clean for RPi.GPIO
Failed to build spidev RPi.GPIO
ERROR: Could not build wheels for spidev which use PEP 517 and cannot be installed directly

minipip returned with error code 1
2

There are 2 best solutions below

0
On

The package mfrc522 from PyPi is only suitable for Python, not for MicroPython although it is installable of course.

I recommend having a look at the Awsome MicroPython page

A curated list of awesome MicroPython libraries, frameworks, software and resources.

At their NFC section you can find MicroPython NFC which can be used to interact with MFRC522, or you give micropython-mfrc522 by wendlers a try. According to the number of stars and forks on GitHub this might be the better lib

0
On

I downloaded mfrc522-python but it was a dummy file and didn't help.