Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: gatorback on February 27, 2020, 10:24:19 AM
-
smbus is required for a relayboard (http://forum.tinycorelinux.net/index.php/topic,23561.0.html) and is a hurdle to overcome before trying the suggestion to create an python extension. (http://forum.tinycorelinux.net/index.php/topic,23561.0.html)
From the python console smbus is not found with (sudo) Python3.6 and returns:
>>>import smbus
ModuleNotFoundError: No module named 'smbus'
python 2.7 on the other hand loads smbus.
>>> import smbus
>>>
Why is Python 3.6 not successful finding smbus and what will remedy the issue? What diagnostics can be performed to determine root-cause?
-
Is it smbus2?
-
Good question! How can one determine version of the smbus extension?
/mnt/mmcblk0p2/tce/optional/py-smbus.tcz
was downloaded (http://forum.tinycorelinux.net/index.php?topic=20291.0) from:
wget http://tinycorelinux.net/7.x/armv6/tcz/py-smbus.tcz
(http://wget http://tinycorelinux.net/7.x/armv6/tcz/py-smbus.tcz)
$ md5sum /mnt/mmcblk0p2/tce/optional/py-smbus.tcz
0e8df4164f50c957b7281fd018472e8d /mnt/mmcblk0p2/tce/optional/py-smbus.tcz
-
Does a version3 of py-smbus exist?
tc@box:~/megaio-rpi/python/megaio$ wget http://tinycorelinux.net/9.x/armv6/tcz/py-smbus.tcz
Connecting to tinycorelinux.net (89.22.99.37:80)
wget: server returned error: HTTP/1.1 404 Not Found
tc@box:~/megaio-rpi/python/megaio$ wget http://tinycorelinux.net/8.x/armv6/tcz/py-smbus.tcz
Connecting to tinycorelinux.net (89.22.99.37:80)
wget: server returned error: HTTP/1.1 404 Not Found
-
if you look at:
http://tinycorelinux.net/7.x/armv6/tcz/py-smbus.tcz.info
http://tinycorelinux.net/7.x/armv6/tcz/py-smbus.tcz.list
..you can see the details.
What I meant was that the python package available from pip for python3.6 might be called smbus2
To compile it I guess you need:
https://files.pythonhosted.org/packages/6a/06/80a6928e5cbfd40c77c08e06ae9975c2a50109586ce66435bd8166ce6bb3/smbus2-0.3.0.tar.gz
-
Thank you for the links and orientation: is the compile process the same as your recommendation in your other posting?:
http://forum.tinycorelinux.net/index.php/topic,23561.0.html
Have you had success in the past compiling 2.X source code with 3.X tools? My intuition tells me this may not be a simple "crank the handle" exercise. Again, your experience is appreciated. If successful, I would be happy to submit the results for the library for other users to enjoy
-
Hi gatorback
... If successful, I would be happy to submit the results for the library for other users to enjoy
Instructions for submitting extensions can be found here:
http://wiki.tinycorelinux.net/wiki:creating_extensions#submitting
-
Most python source code seems to compile equally well with python2.x or python3.x
From a quick look at the smbus2 source, it looks like the same instructions would work - which version of piCore are you using?
-
PiCore 9.03. Good to hear that your intuition indicates an optimistic forecast. README.rst indicates a "pure python" implementation:
smbus2 is (yet another) pure Pythob implementation of the `python-smbus <http://www.lm-sensors.org/browser/i2c-tools/trunk/py-smbus/>`_ package.
This leads me to wonder if this provides any assurance that compiling with Python 3.X will be successful.
-
This leads me to wonder if this provides any assurance that compiling with Python 3.X will be successful.
It only takes a couple of minutes to try and see :)
-
UPDATE:
I am excited at the prospect of creating a .tcz file: here is the log (https://pastebin.com/raw/EQsiJTPU)! After the smbus.tcz file was created: I have configure /tce/onboot.lst to load smbus.tcz at boot time. The newly complied extension is saved to /tce/optional/: changes were backed-up with: filetool.sh -b
ROADBLOCK:
The new smbus.tcz loaded, however smbus did not import into python3.6 or 2.7:
tc@box:~$ cd /mnt/mmcblk0p2/tce/optional/
tc@box:/mnt/mmcblk0p2/tce/optional$ md5sum -c py-smbus3.tcz.md5.txt
py-smbus3.tcz: OK
tc@box:/mnt/mmcblk0p2/tce/optional$ md5sum py-smbus3.tcz
1427ef7aa496489aea6e596bc343f053 py-smbus3.tcz
tc@box:/mnt/mmcblk0p2/tce/optional$ md5sum py-smbus.tcz
1427ef7aa496489aea6e596bc343f053 py-smbus.tcz
tc@box:/mnt/mmcblk0p2/tce/optional$ tce-load -i py-smbus.tcz
py-smbus.tcz: OK
tc@box:/mnt/mmcblk0p2/tce/optional$ tce-load -i py-smbus.tcz
py-smbus is already installed!
tc@box:/mnt/mmcblk0p2/tce/optional$ sudo python3.6
Python 3.6.0 (default, Dec 23 2016, 19:26:34)
[GCC 6.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smbus
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'smbus'
>>>
Did I miss a step somewhere? What tests can be done to determine why module is not found?
-
It should look like this, no:
$ tce-load -i py3.6-smbus2.tcz
py3.6-smbus2.tcz: OK
$ python3.6
Python 3.6.9 (default, Dec 11 2019, 17:44:28)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smbus2
>>>