0

I am trying to send can message using can-python library Getting below error AttributeError: module 'can' has no attribute 'interface'

can-python version :3.3.4 python version :3

code

import can

def send():
bus = can.interface.Bus()
msg = can.Message(arbitration_id=0x68005,data=[0x10,0x11,0x12],is_extended_id=True)
try:
     bus.send(msg)
     print("Message sent on {}".format(bus.channel_info))
except can.CanError:
    print("Message NOT sent")'

if __name__ == '__main__':
    send()

I followed this AttributeError when using python-can (module 'can' has no attribute 'interface')

didnt work for me

Kian
  • 11
  • 5
  • 2
    Does this answer your question? [AttributeError when using python-can (module 'can' has no attribute 'interface')](https://stackoverflow.com/questions/64022196/attributeerror-when-using-python-can-module-can-has-no-attribute-interface) – Hantsaniala Eléo May 13 '21 at 15:42
  • @HantsanialaEléo,answer mentioned in the post doesnot work for me – Kian May 14 '21 at 08:34

1 Answers1

1

Try to downgrade to python-can to version 2 and upgrade after that. I don't know how but that fixed the error. But after that you must specify a bus type or you'll get NotImplementedError: Invalid CAN Bus Type - None.

Here is what I've done :

$ pip install python-can==2
$ pip install python-can --upgrade
  • 2
    Just figured out I had named file as can.py which was throwing error , I changed it other name and worked, no other changes. – Kian May 14 '21 at 14:35