python-can==4.0.0 not working
Opened this issue · 13 comments
Hi, for me the latest python-can 4.0.0 is not working. I am getting:
ERROR - Error opening bus can0 Traceback (most recent call last): File "/usr/lib/python3/dist-packages/HPSU/canpi.py", line 23, in __init__ self.bus = can.interface.Bus(channel='can0', bustype='socketcan_native') File "/usr/lib/python3.9/site-packages/can/interface.py", line 101, in __new__ kwargs = load_config(config=kwargs, context=context) File "/usr/lib/python3.9/site-packages/can/util.py", line 192, in load_config bus_config = _create_bus_config(config) File "/usr/lib/python3.9/site-packages/can/util.py", line 211, in _create_bus_config raise CanInterfaceNotImplementedError( can.exceptions.CanInterfaceNotImplementedError: Unknown interface type "socketcan_native"
It does work with the version before: python-can-3.3.4
Anyone else experiencing this? It would be great to have a requirements file with the supported versions.
OK, I fixed it. Basically we were using deprecated socketcan_native which was removed in v. 4 and also extended_id (now is_extended_id ) , see https://python-can.readthedocs.io/en/master/interfaces/socketcan.html
Should I generate a pull request to master or testing or both?
Tested it with 4.0.0, 3.3.4 and 3.0.0 and it is working for me. I think these things were deprecated for a while and were finally removed. I will generate pull request to testing, which I hope can be merged into master soon. Or is there anything that works in master but not in testing currently?
Which distribution are do you use?
alpine 3.13 or higher (not sure any more, it is in a docker image).
https://hub.docker.com/r/mreuter/armv7-pyhpsu2mqtt
as a HomeAssistant AddOn.
I have to reopen it...
I stumbled on a users machine with installed python-can 4.0.0
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/HPSU/canpi.py", line 23, in init
self.bus = can.interface.Bus(channel='can0', bustype='socketcan_native')
AttributeError: module 'can' has no attribute 'interface'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/HPSU/canpi.py", line 23, in init
self.bus = can.interface.Bus(channel='can0', bustype='socketcan_native')
AttributeError: module 'can' has no attribute 'interface'
Seems, that 4.0.0 has no "interface" attribute.
Needs a second look.
Are you using the testing branch? Based on the error message I think not. In my fix in #54 I had changed the bus type to socetcan (socketcan_native has been removed in 4.0 after a long depreciation period).
Line 23 in de88ca7
About "interface" it should work (at least it worked for me on 4.0 and also one of the examples in the above socket can link uses can.interface.bus (scroll down to broadcast manager). I am not familiar with socket can, so not sure what will happen if you simply remove the "interface". But first test if this is not a different problem (Bustype).
Sorry, thats wrong....
Even the example on the python-can doc shows the "interface" attribute. Wtf.....
Yes, but your error message
line 23, in init self.bus = can.interface.Bus(channel='can0', bustype='socketcan_native')
indicates that you are not using the testing branch, but maybe master? There should be no socketcan_native in our code any longer.
The python3-can package was updated on my raspberry pi, had to change
From:
self.bus = can.interface.Bus(channel='can0', bustype='socketcan_native')
To:
self.bus = can.Bus(channel='can0', interface='socketcan')