Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smbus is not recognized #41

Closed
2 of 3 tasks
AndyBaBaBoi opened this issue Jan 4, 2022 · 20 comments · Fixed by #46
Closed
2 of 3 tasks

smbus is not recognized #41

AndyBaBaBoi opened this issue Jan 4, 2022 · 20 comments · Fixed by #46
Assignees
Labels

Comments

@AndyBaBaBoi
Copy link

AndyBaBaBoi commented Jan 4, 2022

Describe the bug
When I type ‘python demo_lcd.py’ there is an error where it says that in line 1 of init or somewhere in drivers that ‘from smbus import SMBus’ smbus is not reconized or smth.

Executed command and associated error

python demo_lcd
Type error: smbus not reconized

Host and software info

  • RPi board version: latest one
  • OS version: raspian latest one
  • (If Python related.) Python version : version 3
  • (If shell related.) Shell: add name here and version

Checklist

  • I have watched and followed the instructions in the Youtube tutorial.
  • I have searched open and closed issues for either an identical or similar bug before reporting this new one.
  • (If Python related.) I have used Python 2.7
@AndyBaBaBoi AndyBaBaBoi added the bug label Jan 4, 2022
@cgomesu
Copy link
Collaborator

cgomesu commented Jan 4, 2022

Type error: smbus not reconized

paste the entire output instead

Python version : version 3

be more specific. 3.5, 3.7, 3.9, 3.10?

  • (If Python related.) I have used Python 2.7

here is the culprit. the lcd drive and demos were meant to be used with Python 2.7. Python 3.x may or may not work. in any case, the error you are seeing has to do with a missing smbus pkg in your Python 3.x standard library. you can try installing it manually to fix the issue:

sudo apt update && sudo apt install python3-smbus

@cgomesu cgomesu self-assigned this Jan 4, 2022
@cgomesu cgomesu added compatibility and removed bug labels Jan 4, 2022
@AndyBaBaBoi
Copy link
Author

AndyBaBaBoi commented Jan 4, 2022

Ok thx ill try that after school…and tell the creator of this that he/she is a legend for making this.

Oh also I just looked through some of the closed issues and there were a few people with the same issue so it may be wise to say that if u r on x versions then do y if this error shows up or smth

@cgomesu
Copy link
Collaborator

cgomesu commented Jan 4, 2022

Ok thx ill try that after school…and tell the creator of this that he/she is a legend for making this.

sounds good, @AndyBaBaBoi . the repo was created by Matt (@the-raspberry-pi-guy). I just help maintaining it.

Oh also I just looked through some of the closed issues and there were a few people with the same issue

if you are referring to #42, #43, and #44, their issue seems to be different because they were using python 2.7.18 instead of python 3.x, like yourself.

so it may be wise to say that if u r on x versions then do y if this error shows up or smth

changes that improve compatibility are always welcomed. to contribute to the project, please read our CONTRIBUTING.md guide.

@AndyBaBaBoi
Copy link
Author

ok so @cgomesu i went ahead and did as you recommended and this happened:

pi@raspberrypi:~/lcd $ sudo apt update && sudo apt install python3-smbus Hit:1 http://raspbian.raspberrypi.org/raspbian bullseye InRelease Hit:2 http://archive.raspberrypi.org/debian bullseye InRelease Reading package lists... Done Building dependency tree... Done Reading state information... Done All packages are up to date. Reading package lists... Done Building dependency tree... Done Reading state information... Done python3-smbus is already the newest version (4.2-1+b1). The following packages were automatically installed and are no longer required: libfuse2 python-is-python2 Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

so i then went ahead and did this:

pi@raspberrypi:~/lcd $ python demo_lcd.py Traceback (most recent call last): File "demo_lcd.py", line 8, in <module> import drivers File "/home/pi/lcd/drivers/__init__.py", line 1, in <module> from .i2c_dev import Lcd, CustomCharacters File "/home/pi/lcd/drivers/i2c_dev.py", line 1, in <module> from smbus import SMBus ImportError: No module named smbus

do you know why it is not connecting reconizing smbus?

@cgomesu
Copy link
Collaborator

cgomesu commented Jan 4, 2022

paste the output of the following:

hostnamectl
python --version
pip list
python3 --version
pip3 list

@AndyBaBaBoi
Copy link
Author

AndyBaBaBoi commented Jan 4, 2022

ok @cgomesu

hostnamectl:

Static hostname: raspberrypi
         Icon name: computer
        Machine ID: ******************************************
           Boot ID: ******************************************
  Operating System: Raspbian GNU/Linux 11 (bullseye)
            Kernel: Linux 5.10.63-v7l+
      Architecture: arm

python --version:

Python 2.7.18

pip list:

Package           Version
----------------- ---------
appdirs           1.4.4
arandr            0.1.10
astroid           2.5.1
asttokens         2.0.4
automationhat     0.2.0
backcall          0.2.0
beautifulsoup4    4.9.3
blinker           1.4
blinkt            0.1.2
buttonshim        0.0.2
Cap1xxx           0.1.3
certifi           2020.6.20
chardet           4.0.0
click             7.1.2
colorama          0.4.4
colorzero         1.1
cryptography      3.3.2
cupshelpers       1.0
cycler            0.10.0
dbus-python       1.2.16
decorator         4.4.2
distro            1.5.0
docutils          0.16
drumhat           0.1.0
envirophat        1.0.0
ExplorerHAT       0.4.2
Flask             1.1.2
fourletterphat    0.1.0
gpiozero          1.6.2
guizero           1.1.1
gyp               0.1
html5lib          1.1
idna              2.10
ipykernel         5.4.3
ipython           7.20.0
ipython-genutils  0.2.0
isort             5.6.4
itsdangerous      1.1.0
jedi              0.18.0
Jinja2            2.11.3
jupyter-client    6.1.11
jupyter-core      4.7.1
kiwisolver        1.3.1
lazy-object-proxy 0.0.0
logilab-common    1.8.1
lxml              4.6.3
MarkupSafe        1.1.1
matplotlib        3.3.4
mccabe            0.6.1
mfrc522           0.0.7
microdotphat      0.2.1
mock              4.0.3
mote              0.0.4
motephat          0.0.3
mypy              0.812
mypy-extensions   0.4.3
nudatus           0.0.5
numpy             1.19.5
oauthlib          3.1.0
olefile           0.46
pantilthat        0.0.7
parso             0.8.1
pbr               5.5.0
pexpect           4.8.0
pgzero            1.2
phatbeat          0.1.1
pianohat          0.1.0
picamera          1.13
pickleshare       0.7.5
piglow            1.2.5
pigpio            1.78
Pillow            8.1.2
pip               20.3.4
prompt-toolkit    3.0.14
psutil            5.8.0
pycairo           1.16.2
pycodestyle       2.6.0
pycups            2.0.1
pyflakes          2.2.0
pygame            1.9.6
Pygments          2.7.1
PyGObject         3.38.0
pyinotify         0.9.6
PyJWT             1.7.1
pylint            2.7.2
pyOpenSSL         20.0.1
pyparsing         2.4.7
PyQt5             5.15.2
PyQt5-sip         12.8.1
pyserial          3.5b0
pysmbc            1.0.23
python-apt        2.2.1
python-dateutil   2.8.1
pyzmq             20.0.0
QScintilla        2.11.6
qtconsole         5.0.2
QtPy              1.9.0
rainbowhat        0.1.0
reportlab         3.5.59
requests          2.25.1
requests-oauthlib 1.0.0
responses         0.12.1
roman             2.0.0
RPi.GPIO          0.7.0
RTIMULib          7.2.1
scrollphat        0.0.7
scrollphathd      1.2.1
semver            2.10.2
Send2Trash        1.6.0b1
sense-emu         1.2
sense-hat         2.2.0
setuptools        52.0.0
simplejson        3.17.2
six               1.16.0
skywriter         0.0.7
sn3218            1.2.7
soupsieve         2.2.1
spidev            3.5
ssh-import-id     5.10
thonny            3.3.14
toml              0.10.1
tornado           6.1
touchphat         0.0.1
traitlets         5.0.5
twython           3.8.2
typed-ast         1.4.2
typing-extensions 3.7.4.3
uflash            1.2.4
unicornhathd      0.0.4
urllib3           1.26.5
wcwidth           0.1.9
webencodings      0.5.1
Werkzeug          1.0.1
wheel             0.34.2
wrapt             1.12.1

python3 --version:

Python 3.9.2

pip3 list:

Package           Version
----------------- ---------
appdirs           1.4.4
arandr            0.1.10
astroid           2.5.1
asttokens         2.0.4
automationhat     0.2.0
backcall          0.2.0
beautifulsoup4    4.9.3
blinker           1.4
blinkt            0.1.2
buttonshim        0.0.2
Cap1xxx           0.1.3
certifi           2020.6.20
chardet           4.0.0
click             7.1.2
colorama          0.4.4
colorzero         1.1
cryptography      3.3.2
cupshelpers       1.0
cycler            0.10.0
dbus-python       1.2.16
decorator         4.4.2
distro            1.5.0
docutils          0.16
drumhat           0.1.0
envirophat        1.0.0
ExplorerHAT       0.4.2
Flask             1.1.2
fourletterphat    0.1.0
gpiozero          1.6.2
guizero           1.1.1
gyp               0.1
html5lib          1.1
idna              2.10
ipykernel         5.4.3
ipython           7.20.0
ipython-genutils  0.2.0
isort             5.6.4
itsdangerous      1.1.0
jedi              0.18.0
Jinja2            2.11.3
jupyter-client    6.1.11
jupyter-core      4.7.1
kiwisolver        1.3.1
lazy-object-proxy 0.0.0
logilab-common    1.8.1
lxml              4.6.3
MarkupSafe        1.1.1
matplotlib        3.3.4
mccabe            0.6.1
mfrc522           0.0.7
microdotphat      0.2.1
mock              4.0.3
mote              0.0.4
motephat          0.0.3
mypy              0.812
mypy-extensions   0.4.3
nudatus           0.0.5
numpy             1.19.5
oauthlib          3.1.0
olefile           0.46
pantilthat        0.0.7
parso             0.8.1
pbr               5.5.0
pexpect           4.8.0
pgzero            1.2
phatbeat          0.1.1
pianohat          0.1.0
picamera          1.13
pickleshare       0.7.5
piglow            1.2.5
pigpio            1.78
Pillow            8.1.2
pip               20.3.4
prompt-toolkit    3.0.14
psutil            5.8.0
pycairo           1.16.2
pycodestyle       2.6.0
pycups            2.0.1
pyflakes          2.2.0
pygame            1.9.6
Pygments          2.7.1
PyGObject         3.38.0
pyinotify         0.9.6
PyJWT             1.7.1
pylint            2.7.2
pyOpenSSL         20.0.1
pyparsing         2.4.7
PyQt5             5.15.2
PyQt5-sip         12.8.1
pyserial          3.5b0
pysmbc            1.0.23
python-apt        2.2.1
python-dateutil   2.8.1
pyzmq             20.0.0
QScintilla        2.11.6
qtconsole         5.0.2
QtPy              1.9.0
rainbowhat        0.1.0
reportlab         3.5.59
requests          2.25.1
requests-oauthlib 1.0.0
responses         0.12.1
roman             2.0.0
RPi.GPIO          0.7.0
RTIMULib          7.2.1
scrollphat        0.0.7
scrollphathd      1.2.1
semver            2.10.2
Send2Trash        1.6.0b1
sense-emu         1.2
sense-hat         2.2.0
setuptools        52.0.0
simplejson        3.17.2
six               1.16.0
skywriter         0.0.7
sn3218            1.2.7
soupsieve         2.2.1
spidev            3.5
ssh-import-id     5.10
thonny            3.3.14
toml              0.10.1
tornado           6.1
touchphat         0.0.1
traitlets         5.0.5
twython           3.8.2
typed-ast         1.4.2
typing-extensions 3.7.4.3
uflash            1.2.4
unicornhathd      0.0.4
urllib3           1.26.5
wcwidth           0.1.9
webencodings      0.5.1
Werkzeug          1.0.1
wheel             0.34.2
wrapt             1.12.1

@cgomesu
Copy link
Collaborator

cgomesu commented Jan 4, 2022 via email

@cgomesu cgomesu added bug and removed compatibility labels Jan 5, 2022
@cgomesu
Copy link
Collaborator

cgomesu commented Jan 5, 2022

found the issue (also related to #42, #43, #44):

working on a solution via a change to setup.sh.


in the meantime, @AndyBaBaBoi (and @JoshyOnMars), if you have already installed pyhton3-smbus, you should be able to use the lcd driver with python3 instead. for example, to run the demo demo_lcd.py, use the following:

python3 demo_lcd.py

please do not close this issue if the above solution works for you. I'll close it once I merge a fix for the python2 issue.

@AndyBaBaBoi
Copy link
Author

@cgomesu ok so it works in printing that it is writing to display but it is not showing up on the screen

@AndyBaBaBoi
Copy link
Author

66311076838__ABF83081-B4F1-4FC8-A607-56B0DBCF6A20.MOV

@AndyBaBaBoi
Copy link
Author

AndyBaBaBoi commented Jan 6, 2022

YESSSSS I GOT IT TO WORK i literally twisted the thing on the back the little plus sign BUT IT WORKS

@cgomesu
Copy link
Collaborator

cgomesu commented Jan 6, 2022

YESSSSS I GOT IT TO WORK i literally twisted the thing on the back the little plus sign BUT IT WORKS

this was explained in the tutorial: https://www.youtube.com/watch?v=fR5XhHYzUK0&t=410s

@AndyBaBaBoi
Copy link
Author

AndyBaBaBoi commented Jan 6, 2022

Oh lol i literally watched until literally 1 second before it but also do u think the display could be able to rick roll someone? I mean it would take a bit of work for the custom characters for that but it would be worth it

@cgomesu
Copy link
Collaborator

cgomesu commented Jan 6, 2022

Oh lol i literally watched until literally 1 second before it but also do u think the display could be able to rick roll someone? I mean it would take a bit of work for the custom characters for that but it would be worth it

there's a lot that can be done but you will be working with a very limited amount of memory. per @juvus' comments in the demo_lcd_custom_characters.py example, you can define and store custom characters in the custom generated random access memory (cg-ram) of the lcd controller, which is 64 Bytes long and because each character uses 8 Bytes, you can only define 8 custom characters that way.

@AndyBaBaBoi
Copy link
Author

AndyBaBaBoi commented Jan 6, 2022

Ohhhh I see. So would that in theory mean that each frame of the “rick roll” would have to use less than 8 custom characters per frame? Like i could make an infinite amount of them but only load up to eight at a time or can i only create 8 overall. If that is the case could I do some thing where like each frame x list becomes cc1 and y list becomes cc2 and i can replace the 8 with new ones each frame and with that I would have to load it to cg each time?

@juvus
Copy link
Contributor

juvus commented Jan 7, 2022

Ohhhh I see. So would that in theory mean that each frame of the “rick roll” would have to use less than 8 custom characters per frame? Like i could make an infinite amount of them but only load up to eight at a time or can i only create 8 overall. If that is the case could I do some thing where like each frame x list becomes cc1 and y list becomes cc2 and i can replace the 8 with new ones each frame and with that I would have to load it to cg each time?

Hi, AndyBaBaBoi.
Of course you can define any amount of you own characters and store it, for example, in the python list or dictionary, but you can upload to the LCD cg-ram no more than 8 characters data at a time. During the work of your program you can easily upload new characters data to the cg-ram (by invoking load_custom_characters_data() method). But, please, be noted, that if you redefine any custom character in the memory, it will be immediately updated on the LCD screen with the new character data. So, the general conclusion here is that it is not possible to display more than 8 custom characters on the display at the same frame (at the same time).

@AndyBaBaBoi
Copy link
Author

AndyBaBaBoi commented Jan 7, 2022

OK I see now but just to clarify:

This will not work as when I do cc.load_custom_characters_data() it would try to load 9 cc and not up to 8 as it is supposed to?

cc.char_8_data = ["11111",
                              "10001",
                              "11111",
                              "00000",
                              "00000",
                              "11111",
                              "10001",
                              "11111"]

But I am able to do this and to then do cc.load_custom_characters_data() and have different ones like

cc_frame1box8 = ["11111",
                              "10001",
                              "11111",
                              "00000",
                              "00000",
                              "11111",
                              "10001",
                              "11111"]
cc.char_8_data = cc_frame1box8

@juvus or @cgomesu

@AndyBaBaBoi
Copy link
Author

Also @cgomesu how do i use it with these pinns?
01B48E0B-8D70-46F3-9113-7C1FAAFF87EB

@cgomesu
Copy link
Collaborator

cgomesu commented Jan 10, 2022

@AndyBaBaBoi, please keep the discussion in this thread about the reported bug. if you have unrelated questions, open a new issue. be mindful that most of us do this in their spare time, so we won't be able to help on a regular basis.

@juvus
Copy link
Contributor

juvus commented Jan 10, 2022

Hi, @AndyBaBaBoi!
As I understood from the previous conversations, you are a schollboy - young person which is interested in electronics, programming and with a lot of questions about different issues. This is very good, and a young person should be like this! Try to find the answers to you questions by you own, try to figure out how to make a good questions to Google, find information, weed out unrelated info and so on. This is very important skill nowadays. Try to run different code and see what happens, do not affraid to fail. You can easily download a library from github, change the code, understand how it works. Try to be independent! Only this way you will became a very quilified professional in whatever field you want! I wish you good luck!

@cgomesu cgomesu mentioned this issue Jan 13, 2022
@cgomesu cgomesu linked a pull request Jan 13, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants