pi_ina219: Library is not compatible with Python 3

These errors occur:

Traceback (most recent call last):
  File "example.py", line 4, in <module>
    from ina219 import INA219
  File "/home/pi/pi_ina219/ina219.py", line 7, in <module>
    import Adafruit_GPIO.I2C as I2C
ImportError: No module named 'Adafruit_GPIO'

and:

  File "example.py", line 14
    print "Bus Voltage    : %.3f V" % ina.voltage()

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

On a new installation of Raspbian I did:

  1. Enabled I2C in raspi-config
  2. Create a python test file containing just the two imports at the top of your file
  3. Ran my test file with python3 -> gave the same import error you get
  4. Installed Adafruit_GPIO with: pip3 install AdaFruit_GPIO
  5. Ran my test file again -> succeeded with no errors

So from this is does look like your system is to blame. So reinstalling Rasbian will work.

Chris

On Sun, Mar 4, 2018 at 12:06 PM, GawiQ notifications@github.com wrote:

LIS3DH_bus1.py.gz https://github.com/chrisb2/pi_ina219/files/1777999/LIS3DH_bus1.py.gz Manual installation didn’t work. Do you think system reinstallation would work? Here is the file

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/chrisb2/pi_ina219/issues/2#issuecomment-370187137, or mute the thread https://github.com/notifications/unsubscribe-auth/AC8dV1HgP2JZYnP2SJ9bT4rTo1uAPXJSks5tayH8gaJpZM4L3C_7 .

To install dependencies for Python 3 on Raspberry Pi, this need to be executed: sudo python3 -m pip install git+git://github.com/chrisb2/pi_ina219.git this fixes the import error above.