To control Sphero with Python, we'll can use:
https://github.com/CMU-ARM/sphero_sprk
The following is some sample code to get you started:
from sphero_sprk import Sphero
orb = Sphero("XX:XX:XX:XX:XX:XX")
orb.connect()
orb.set_rgb_led(255,0,0)
orb.roll(100,0)
To run your Python script do:
$ python3 your_script.py
There are actually several Python libraries to control Sphero, but this one definitely works :). Please take note that it doesn't work on Mac because of compatibility issues with the bluepy
library.