Import the library
The first thing your program does is tell Pybricks: "I want to use the Pathfinder library". Without this line, the hub does not know what MBC_LINE8 means, and you get a NameError.
Pick one library. Both work the same way. Only the import line is different.
- Download the library (save the file and keep its name): MBC_line8.py (only this sensor) or MBC_sensors.py (the all-in-one library). You picked
MBC_line8.py. - In Pybricks Code, press "Import a file" in the file list on the left. Import it into the same project.
- Do not rename the file, and do not put it in a sub-folder.
- Go back to your main program. Write the lines below at the very top (marked ① in the program on the right).