From PyPI:
pip install spikebleFrom GitHub:
pip install git+https://github.com/MGross21/spikeble.git
⚠️ Warning:
It is highly recommended to install and use this library within a Python virtual environment. Installingspikeblewill expose all MicroPython modules (such asapp,color,color_matrix,color_sensor,device,distance_sensor,force_sensor,hub,motor,motor_pair,orientation, andrunloop) as direct imports in your environment. Using a virtual environment prevents conflicts with other Python projects and keeps your global Python installation clean.Making a Python Virtual Environment
python -m venv .venv # Activate the virtual environment # On Windows: venv\Scripts\activate # On macOS/Linux: source venv/bin/activateOnce activated, you can install
spikebleand other dependencies.
To enable auto-complete for MicroPython APIs, place all MicroPython imports inside your main() function.
Use the template below as a starting point for your SPIKE code:
import spikeble
import asyncio
def main():
# from app import sound, bargraph, display, linegraph, music
import color
import color_matrix
import color_sensor
import device
import distance_sensor
import force_sensor
from hub import port, button, light, light_matrix, motion_sensor, sound
import motor
import motor_pair
import orientation
import runloop
### Insert Your Code Here ###
if __name__ == "__main__":
asyncio.run(spikeble.run(main))Note:
As ofSPIKE™ Firmware v1.8.149andRPC v1.0.47, usingimport apporfrom app import ...will result in an import error. Theappmodule is currently disabled until further notice.
You can also run code on the SPIKE using the following methods:
spikeble.run_file("path/to/your_script.py")spikeble.run_str("print('Hello from SPIKE!')")
