Import the library
The Robot Inventor App cannot import files the way Pybricks does, so you install the EXP6 library on the hub once (it goes into /projects/mbc_exp6/ on the hub and survives power-off); after that every Python project just needs three import lines at the top. Without them the hub does not know what MBC_EXP6 means and you get an ImportError or NameError.
- Download MBC_EXP6_Robot_Inventor_Lib.zip (installer, uninstaller and 10 examples). The installer is Install_MBC_exp6_Lib.py; the library it installs is called
MBC_exp6_SPIKE_App_Lib. - Turn the hub on and connect it in the Robot Inventor App: USB cable or Bluetooth, either works (USB is steadier and recommended).
- Make a new Python project, paste the whole of
Install_MBC_exp6_Lib.pyand run it. After about 6 seconds the console prints "安裝成功! (Installed OK)" (after listing all 3 files as OK). - You only do this once. A hub firmware update wipes the library, so install it again afterwards. To remove it, run
Uninstall_MBC_exp6_Lib.pyfrom the download pack. - Make a new Python project and type the three lines below at the very top (marked ① in the program on the right).
First time? Step-by-step version: Robot Inventor install guide. You can install over USB or Bluetooth; USB is recommended.
Only the import line differs from the LEGO SPIKE App (Education): there it is from MBC_exp6_SPIKE_App_Lib import MBC_EXP6; on Robot Inventor it is from projects.mbc_exp6.MBC_exp6_SPIKE_App_Lib import MBC_EXP6.