'CircuitPython: No module named 'usb_hid'

I installed CircuitPython on my Raspberry Pi Zero W and tried to import usb_hid in Python and it threw the error: ModuleNotFoundError: No module named 'usb_hid'. I've spend all day trying to solve this issue to no avail.

I'm running the default Raspberry Pi OS and I used this tutorial to install the CircuitPython libraries.

My end goal is to use my Raspberry Pi as a mouse that controls another device. I modified the code from this tutorial to come up with this code:

import time
import usb_hid
from adafruit_hid.mouse import Mouse

mouse = Mouse(usb_hid.devices)

time.sleep(5)

while True:
    mouse.move(x=100)
    time.sleep(0.5)
    mouse.move(x=-100)
    time.sleep(0.5)

I'm very new to Raspberry Pi's / Python, so maybe I'm just missing something obvious.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source