mpu6050 icon indicating copy to clipboard operation
mpu6050 copied to clipboard

Update to smbus2

Open aaroncwhite opened this issue 3 years ago • 3 comments

Hey, thanks for the library! I've had to update to smbus2 so it plays nice with another library. Figure it might be useful. Not sure if this is still maintained, but just in case!

aaroncwhite avatar Sep 07 '20 23:09 aaroncwhite

Hey @aaroncwhite, thanks for the pull request!

Is there any particular reason to always want to use smbus2 over the standard python(3)-smbus package? If not, I rather keep this merge request open and refer to it in the README, to have the standard smbus package as the default and let people know that someone also made a fork using smbus2.

m-rtijn avatar Oct 21 '20 09:10 m-rtijn

What about this ?

import imp
try:
    imp.find_module('smbus')
    import smbus
except ImportError as e:
    import smbus2 as smbus

ThinkalVB avatar Sep 21 '21 07:09 ThinkalVB

@ThinkalVB this assumes that if the regular smbus is not available, then smbus2 will be available and/or you want to use smbus2. Which is an assumption that you probably should not make. I think it is better for users to explicitly choose which smbus version they use, either by using the master branch or using the fork by @aaroncwhite.

m-rtijn avatar Sep 25 '21 12:09 m-rtijn