Why do my Python commands not recognize the installed SMbus libraries

Hi
I have been debugging a device using IIC protocol with Jetson Xavier Nx recently. I have identified the device, but there was an error when running the program, which indicated that I did not install the IIC protocol related library. I actually have the SMbus library installed

I have carried out the following orders:

sudo apt-get install python3-smbus
sudo pip3 install smbus
sudo apt-get install l -y i2c-tools

The program I’m running is a column in the link below:

Below is the information that I run the instructions and the program error:

mahan@jsteon-nano-desktop:~/Documents/IIc/MPU-6050-Python-master/MPU-6050-Python-master$ sudo i2cdetect -y -r -a 1
[sudo] password for mahan:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: – – – – – – – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – 68 – – – – – – –
70: – – – – – – – – – – – – – – – –

mahan@jsteon-nano-desktop:~/Documents/IIc/MPU-6050-Python-master/MPU-6050-Python-master$ sudo apt-get install python3-smbus
Reading package lists… Done
Building dependency tree
Reading state information… Done
python3-smbus is already the newest version (4.0-2).
The following packages were automatically installed and are no longer required:
apt-clone archdetect-deb bogl-bterm busybox-static cryptsetup-bin
dpkg-repack gir1.2-timezonemap-1.0 gir1.2-xkl-1.0 grub-common
kde-window-manager kinit kio kpackagetool5 kwayland-data kwin-common
kwin-data kwin-x11 libaio1 libdebian-installer4 libibverbs1
libkdecorations2-5v5 libkdecorations2private5v5 libkf5activities5
libkf5attica5 libkf5completion-data libkf5completion5 libkf5declarative-data
libkf5declarative5 libkf5doctools5 libkf5globalaccel-data libkf5globalaccel5

mahan@jsteon-nano-desktop:~/Documents/IIc/MPU-6050-Python-master/MPU-6050-Python-master$ sudo pip3 install smbus
The directory ‘/home/mahan/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
The directory ‘/home/mahan/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Requirement already satisfied: smbus in /usr/local/lib/python3.6/dist-packages

mahan@jsteon-nano-desktop:~/Documents/IIc/MPU-6050-Python-master/MPU-6050-Python-master$ sudo apt-get install l -y i2c-tools
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package l
mahan@jsteon-nano-desktop:~/Documents/IIc/MPU-6050-Python-master/MPU-6050-Python-master$ apt-cache search smbus
python-smbus - Python bindings for Linux SMBus access through i2c-dev
python3-smbus - Python 3 bindings for Linux SMBus access through i2c-dev

mahan@jsteon-nano-desktop:~/Documents/IIc/MPU-6050-Python-master/MPU-6050-Python-master$ python MPU6050.py
Traceback (most recent call last):
File “MPU6050.py”, line 8, in
import smbus
ModuleNotFoundError: No module named ‘smbus’

Hi,

Could you try it with python3 to see if it works?

$ python3 MPU6050.py

Thanks.

Hi,

Yes I tried it and the result was the same as performing python MPU6050.py, both showed no smbus.

mahan@jsteon-nano-desktop:~/Documents/IIc/MPU-6050-Python-master/MPU-6050-Python-master$ python3 MPU6050.py
Traceback (most recent call last):
File “MPU6050.py”, line 8, in
import smbus
ModuleNotFoundError: No module named ‘smbus’

Hi,

Just give it a try, the smbus module can be imported on Jetson without issues.
Would you mind checking it again?

$ sudo pip3 install smbus
The directory '/home/nvidia/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/nvidia/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting smbus
  Downloading https://files.pythonhosted.org/packages/4d/5c/70e14aa4f0c586efc017e1d1aa6e2f7921eefc7602fc2d03368ff912aa91/smbus-1.1.post2.tar.gz (104kB)
    100% |████████████████████████████████| 112kB 1.9MB/s
Installing collected packages: smbus
  Running setup.py install for smbus ... done
Successfully installed smbus-1.1.post2
$ python3
Python 3.6.9 (default, Mar 15 2022, 13:55:28)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smbus
>>>

Thanks.

Hi,

When I execute sudo pip3 install smbus, I get the following prompts:

The directory ‘/home/mahan/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
The directory ‘/home/mahan/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Requirement already satisfied: smbus in /usr/local/lib/python3.6/dist-packages

When I execute python3, I get the following prompts:

mahan@jsteon-nano-desktop:~$ python3
Python 3.7.5 (default, Dec 9 2021, 17:04:37)
[GCC 8.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import smbus
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘smbus’

Is there a problem with the installed Version of Python?

Hi,

When I run sudo pip3 install smbus, the following message appears:

mahan@jsteon-nano-desktop:~$ sudo pip3 install smbus
The directory ‘/home/mahan/.cache/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
The directory ‘/home/mahan/.cache/pip’ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag.
Requirement already satisfied: smbus in /usr/local/lib/python3.6/dist-packages

When I run python3, the following message appears:

mahan@jsteon-nano-desktop:~$ python3
Python 3.7.5 (default, Dec 9 2021, 17:04:37)
[GCC 8.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import smbus
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘smbus’

Is there a problem with the installed Version of Python?

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