[英]Showing ImportError: cannot import name 'Message' from 'can'
I am importing CAN messages in Python
and I am using python-can
library.我在
Python
中导入 CAN 消息,我正在使用python-can
库。 So the line in my python code here is:所以我的python代码中的行是:
from can import Message
It was working fine but after I changed the folders, I am getting the below error:它工作正常,但在我更改文件夹后,我收到以下错误:
Traceback (most recent call last):
File "/home/rafi/PycharmProjects/Right Turn/CAN_simulator_Recv.py", line 12, in <module>
from can import Message
ImportError: cannot import name 'Message' from 'can' (/home/rafi/.local/lib/python3.8/site-packages/can/__init__.py)
Can anyone help me with this error?谁能帮我解决这个错误? Maybe it has something to do with directory or packages?
也许它与目录或包有关? The same
can
library is working fine in other linux machines.相同的
can
库在其他 linux 机器上运行良好。 I tried uninstalling python-can
but it doesn't work.我尝试卸载
python-can
但它不起作用。 Please help.请帮忙。
It's some kind of import bug.这是某种导入错误。 Try import Message like this:
尝试像这样导入消息:
from can.message import Message
Everything worked for me.一切都对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.