Module 'ctre' has no attribute 'sensors'

We have recently got a new gyro and tried to use it. A few deploys later and we got this attribute error. It states that the “module ‘ctre’ has no attribute ‘sensors’”. At first, we thought this had to do with the robotpy version but we have the latest version (2023.1.0). After referring to the robotpy ctre github we verified that we have the latest version and checked to see if there was any documentation about the error but didnt find much. Does anyone know what the problem is or how we can fix it?

RobotPy does not install ctre by default, so that isn’t a guarantee that you installed the latest (or any) version of the ctre library.

Please post the output of pip list if you’re running into this problem in simulation, or the output of robotpy-installer list if you’re running into this problem on the robot.

Also, I just noticed that ctre does not import sensors by default, so you would need to add a import ctre.sensors to your file before accessing ctre.sensors.XXX would work.

The output of robotpy-installer list is this:

I think if you add a import ctre.sensors then you will no longer have the error.

Okay, thank you so much.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.