运行以下代码时出现错误:
import can #importing CAN module
import time
bus1 = can.interface.Bus(bustype='vector', channel=0, bitrate=500000,
app_name='python-can')
bus2 = can.interface.Bus(bustype='vector', channel=1, bitrate=500000,
app_name='python-can')
msg1 = can.Message(arbitration_id = 0xa1,
data = [1, 2, 3, 4, 5, 6, 7, 8],
extended_id = False)
msg2 = can.Message(arbitration_id = 0xa3,
data = [8, 7, 6, 5, 4, 3, 2, 1],
extended_id = False)
bus1.send(msg1)
time.sleep(1.0)
bus2.send(msg2)
bus1.shutdown()
bus2.shutdown()我可以导入can模块,但是我得到了这个错误:
AttributeError: module 'can' has no attribute 'interface'我正在尝试向虚拟CAN发送虚拟消息。如何修复此错误?
发布于 2020-10-09 23:49:04
我今天在使用python-can 3.3.3时遇到了这个问题,并通过更新到不久前发布的3.3.4解决了这个问题。
由于该包仍在开发中,看起来他们意外地发布了3.3.3的损坏版本。
发布于 2020-10-28 22:33:01
如果在打包为.exe的.py之后,Pyinstaller4.0出现这个问题,请在代码中添加以下行;
import can.interfaces.vectorhttps://stackoverflow.com/questions/64022196
复制相似问题