【ROS】ImportError: No module named xxxxx.msg 解决方法

【ROS】ImportError: No module named xxxxx.msg/srv解决方法

1.先尝试下面这个文章的方法

链接
如果发现问题依旧存在,请往下看

2.问题依然存在

描述:我的工程中曾因为python文件和功能包文件名称重复报错 “ImportError: No module named msg

我的功能包为“person_detection”,我的python文件为“person_detection.py”,因为名称重复,我便将python文件名改为“person_detect.py”

改正后又提示标题的错误

查看控制台信息
Traceback (most recent call last):
  File "/home/passoni/wheeltec_robot_assist/src/person_detection/scripts/person_detect.py", line 13, in <module>
    from person_detection.msg import position as PositionMsg
  File "/home/passoni/wheeltec_robot_assist/src/person_detection/scripts/person_detection.py", line 13, in <module>
ImportError: No module named msg
[person_detection_node-1] process has died [pid 2505, exit code 1, cmd /home/passoni/wheeltec_robot_assist/src/person_detection/scripts/person_detect.py __name:=person_detection_node __log:=/home/passoni/.ros/log/d75035b2-960d-11eb-8dd7-dca632fb6e1d/person_detection_node-1.log].
log file: /home/passoni/.ros/log/d75035b2-960d-11eb-8dd7-dca632fb6e1d/person_detection_node-1*.log

发现第四行出现 “person_detection.py” ,因为我已经将python文件重命名为“person_detect.py”,所以此时这个文件应该是不存在的!!!

进入存放“person_detection.py”的目录,发现 “person_detection.pyc”文件,将其删除即可解决问题

passoni@passoni:~/wheeltec_robot_assist$ cd /home/passoni/wheeltec_robot_assist/src/person_detection/scripts/
passoni@passoni:~/wheeltec_robot_assist/src/person_detection/scripts$ ls
person_detection.pyc  person_detect.py
passoni@passoni:~/wheeltec_robot_assist/src/person_detection/scripts$ rm person_detection.pyc

1.【ROS】ImportError: No module named xxxxx.msg/srv解决方法
2. ImportError: No module named msg 解决方法
3. pyc文件说明

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值