【问题标题】:AttributeError: module 'can' has no attribute 'interface' with version 3.3.4AttributeError:模块 'can' 没有版本 3.3.4 的属性 'interface'
【发布时间】:2021-05-13 15:39:12
【问题描述】:

我正在尝试使用 can-python 库发送 can 消息 低于错误 AttributeError: 模块 'can' 没有属性 'interface'

can-python 版本:3.3.4 蟒蛇版本:3

代码

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()

我关注了这个 AttributeError when using python-can (module 'can' has no attribute 'interface')

对我没用

【问题讨论】:

标签: python-3.x can-bus


【解决方案1】:

尝试将 python-can 降级到第 2 版,然后再升级。我不知道如何解决错误。但在那之后你必须指定一个总线类型,否则你会得到NotImplementedError: Invalid CAN Bus Type - None

这是我所做的:

$ pip install python-can==2
$ pip install python-can --upgrade

【讨论】:

  • 刚刚发现我将文件命名为 can.py 抛出错误,我将其更改为其他名称并正常工作,没有其他更改。
猜你喜欢
  • 2017-08-18
  • 2022-01-27
  • 1970-01-01
  • 2020-01-04
  • 2017-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多