Sparkfun Jetbot problem with importing modules

I’m having issues with importing modules from the jetbot folder. When I run the examples in the notebook,

from jetbot import Robot
robot = Robot()

OSErrorTraceback (most recent call last)
----> 1 robot = Robot()

/usr/local/lib/python3.6/dist-packages/jetbot-0.4.3-py3.6.egg/jetbot/ in init(self, *args, **kwargs)
20 def init(self, *args, **kwargs):
21 super(Robot, self).init(*args, **kwargs)
—> 22 self.motor_driver = Adafruit_MotorHAT(i2c_bus=self.i2c_bus)
23 self.left_motor = Motor(self.motor_driver, channel=self.left_motor_channel, alpha=self.left_motor_alpha)
24 self.right_motor = Motor(self.motor_driver, channel=self.right_motor_channel, alpha=self.right_motor_alpha)

/usr/local/lib/python3.6/dist-packages/Adafruit_MotorHAT-1.4.0-py3.6.egg/Adafruit_MotorHAT/ in init(self, addr, freq, i2c, i2c_bus)
229 self.motors = [ Adafruit_DCMotor(self, m) for m in range(4) ]
230 self.steppers = [ Adafruit_StepperMotor(self, 1), Adafruit_StepperMotor(self, 2) ]
→ 231 self._pwm = PWM(addr, debug=False, i2c=i2c, i2c_bus=i2c_bus)
232 self._pwm.setPWMFreq(self._frequency)

/usr/local/lib/python3.6/dist-packages/Adafruit_MotorHAT-1.4.0-py3.6.egg/Adafruit_MotorHAT/ in init(self, address, debug, i2c, i2c_bus)
57 self.i2c = get_i2c_device(address, i2c, i2c_bus)
58 logger.debug(“Reseting PCA9685 MODE1 (without SLEEP) and MODE2”)
—> 59 self.setAllPWM(0, 0)
60 self.i2c.write8(self.__MODE2, self.__OUTDRV)
61 self.i2c.write8(self.__MODE1, self.__ALLCALL)

/usr/local/lib/python3.6/dist-packages/Adafruit_MotorHAT-1.4.0-py3.6.egg/Adafruit_MotorHAT/ in setAllPWM(self, on, off)
93 def setAllPWM(self, on, off):
94 “Sets a all PWM channels”
—> 95 self.i2c.write8(self.__ALL_LED_ON_L, on & 0xFF)
96 self.i2c.write8(self.__ALL_LED_ON_H, on >> 8)
97 self.i2c.write8(self.__ALL_LED_OFF_L, off & 0xFF)

/usr/local/lib/python3.6/dist-packages/Adafruit_GPIO-1.0.4-py3.6.egg/Adafruit_GPIO/ in write8(self, register, value)
114 “”“Write an 8-bit value to the specified register.”""
115 value = value & 0xFF
→ 116 self._bus.write_byte_data(self._address, register, value)
117 self._logger.debug(“Wrote 0x%02X to register 0x%02X”,
118 value, register)

/usr/local/lib/python3.6/dist-packages/Adafruit_PureIO-1.1.8-py3.6.egg/Adafruit_PureIO/ in write_byte_data(self, addr, cmd, val)
320 # Send the data to the device.
321 self._select_device(addr)
→ 322 self._device.write(data)
324 def write_word_data(self, addr, cmd, val):

OSError: [Errno 121] Remote I/O error

I am using sparkfun’s motor driver and oled and have checked that they are working properly.
Note that these directories in the error do not exist and I have no idea how to redirect them.

Additional info:
-I am running the latest image because older versions and the ones sparkfun provided would not boot (My pc doesn’t detect the Nano at all and it shows the recovery mode when I plug in a display).
-On 1st boot I deleted the jetbot folder and cloned GitHub - sparkfun/jetbot: An educational AI robot based on NVIDIA Jetson Nano. .

Hi @peterygx,

Thanks for reaching out!

This issue typically indicates there is a connection issue with the I2C device, but you mention this is not the case. I’m not immediately sure what the cause is.

The latest JetBot image actually runs the Jupyter Lab server from within a docker container. While the folders you access in Jupyter Lab are mounted to a persistent volume (which will stay after boot). When you install the Sparkfun JetBot library, it’s possible this change is reset at boot, since it is installed elsewhere. This is a limitation that we may need to address in the future, as I can see how this is inconvenient. If this ends up being the cause, it may be possible to build a container with your changes applied.

Did you experience this error immediately after installing the library, or perhaps after a reboot?


Hi @jaybdub ,
It occurs after installing the library and also after rebooting.

The notebook manages to access the python files from the original Nvidia repo even though I have replaced them with the ones from sparkfun in the ~/jetbot/jetbot directory.
Sparkfun has the .py files with the same names but different code directing to the correct drivers.

I tried making a new notebook and copied the cells. It is able to import the files in the ~/jetbot/jetbot folder but not the drivers from /dist-packages

Would rebuilding the container help and if so, how would I do it?