Python Forum

Full Version: SMBUS 'no such file or directory'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Running this little example

import  I2C_LCD_driver 
from time import *
mylcd = I2C_LCD_drive.lcd()
mylcd.lcd_display_string("Hello Python!", 1)
I get this error in I2C_LCD_driver.py taken from https://www.circuitbasics.com/raspberry-...ogramming/
Error:
Python 3.7.3 (/usr/bin/python3) >>> %Run lcd_test.py Traceback (most recent call last): File "/home/pi/Documents/lcd_test.py", line 3, in <module> mylcd = I2C_LCD_driver.lcd() File "/home/pi/Code/I2C_LCD_driver.py", line 109, in __init__ self.lcd_device = i2c_device(ADDRESS) File "/home/pi/Code/I2C_LCD_driver.py", line 30, in __init__ self.bus = smbus.SMBus(port) FileNotFoundError: [Errno 2] No such file or directory >>>
Try to install smbus
Output:
sudo apt-get install python3-smbus
Or perhaps install it from pypi
Output:
python3.7 -m pip install smbus
(Jan-31-2021, 04:19 PM)Gribouillis Wrote: [ -> ]Try to install smbus
Output:
sudo apt-get install python3-smbus
Or perhaps install it from pypi
Output:
python3.7 -m pip install smbus

It's already installed.

Solved! I changed the portnumber from 0 to 1
Output:
smbus.SMBUS(1)