Installing Stockfish on a Raspberry Pi 3 Model B+ (Raspbian OS Lite)

How to install the most recent stockfish chess engine on a Raspberry Pi 3 Model B+ (including NNUE) and working around the stockfish library bugs.

Steps

git clone https://github.com/official-stockfish/Stockfish
cd Stockfish/src
make net
make build ARCH=armv7
pip install stockfish

Attempt to use the python stockfish library:

python
>>> from stockfish import Stockfish
>>> stockfish = Stockfish(path="/path/to/your/Stockfish/src/stockfish")
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/home/YOUR_USER/.local/lib/pythonX.X/site-packages/stockfish/models.py", line 58, in __init__
        self._stockfish_major_version: int = int(
ValueError: invalid literal for int() with base 10: 'dev202301049fe9ff00'

If there is a problem with parsing the stockfish major version, then temporarily fix the models.py by typing a fixed integer value for the major version:

nano /home/YOUR_USER/.local/lib/pythonX.X/site-packages/stockfish/models.py

Change the line: self._stockfish_major_version: int = ... to be a fixed value integer.

python
>>> from stockfish import Stockfish
>>> stockfish = Stockfish(path="/path/to/your/Stockfish/src/stockfish")
>>> stockfish.set_position(["e2e4", "e7e6"])
>>> stockfish.get_best_move()
'd2d4'

References