python - 'can' BLFReader 函数的 Python 属性错误
问题描述
Python 3.9.4 (tags/v3.9.4:1f2e308, Apr 6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import can
>>> filename = "test.blf"
>>> log = can.BLFReader(filename)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'can' has no attribute 'BLFReader'
>>>
我正在尝试使用 Python 导入 CAN blf 文件。
我使用了 can 模块和 BLFReader 函数,但它显示属性错误如上。
我的 python 版本是 3.9.4。
我该如何解决这个问题?
解决方案
BLFReader在包中python-can
,不在can
包中。
卸载can
并安装python-can
:
pip3 uninstall can
pip3 install python-can
然后:
import can
can.BLFReader
# <class 'can.io.blf.BLFReader'>
推荐阅读
- c# - 从 Gridview 中选择级联两个下拉列表的值
- c# - 使用按钮更改xaml,c#中Label的大小文本
- python-3.x - 无法使用 Selenium 在字段中输入文本
- ios - SwiftUI 中有控制器吗?
- haskell - 无法将预期类型“Int -> [Char]”与实际类型“Int”匹配可能的原因:“mod”应用于太多参数
- xslt - XSLT 中的舍入值
- asp.net - 如何使用 asp.net mvc 在我的托管计划中创建子域?
- javascript - QuotaExceededError:已超出配额 - 渐进式 Web 应用离线模式
- java - 无法使用 Spring 和 Hibernate 保存表单数据
- python-2.7 - 从麦克风向 Softbank Nao 人形机器人直播音频