1:python执行时候,报错没有 “message”指令;
PS E:\share\top_hqt409\hq_app\automation\auto_log\src> python .\remote.py
2022-11-12 13:48:25.489 | INFO | hqobos:<module>:98 - load config file,total count:820
Traceback (most recent call last):
File ".\remote-client.py", line 13, in <module>
from can import Message
ImportError: cannot import name 'Message' from 'can' (C:\Users\Pi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\can\__init__.py)
2:查看 CAN模块下已有指令
>>> import can
>>> dir(can) # 查看CAN模块已安装指令
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> can.__path__ # 查看 CAN模块安装路径
['C:\\Users\\Pi\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\can']
>>>
3:发现路径下没有模块对应功能,只有一个空壳
4:测试发现 pip uninsall 之后再安装也没有用;
5:最终处理方法是把 同时电脑下已安装的CAN模块,复制过来替换一下
>>> import can
>>> dir(can)
['ASCReader', 'ASCWriter', 'AsyncBufferedReader', 'BLFReader', 'BLFWriter', 'BufferedReader', 'Bus', 'BusABC', 'BusState', 'CSVReader', 'CSVWriter', 'CanError', 'CanutilsLogReader', 'CanutilsLogWriter', 'CyclicSendTaskABC', 'LimitedDurationCyclicSendTaskABC', 'Listener', 'LogReader', 'Logger', 'Message', 'MessageSync', 'ModifiableCyclicTaskABC', 'MultiRateCyclicSendTaskABC', 'Notifier', 'Printer', 'RedirectReader', 'RestartableCyclicTaskABC', 'SqliteReader', 'SqliteWriter', 'ThreadSafeBus', 'VALID_INTERFACES',
'__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'absolute_import', 'broadcastmanager', 'bus', 'detect_available_configs', 'interface', 'interfaces', 'io', 'listener', 'log', 'logging', 'message', 'notifier', 'rc', 'send_periodic', 'set_logging_level', 'thread_safe_bus', 'util']
>>>
6:具体为什么我电脑不行也搞不清楚, 反正发现这种 pip install安装了一个空壳的模块,可以去官网下载之后在本地安装,或者复制其他人已成功安装的;