链接
如果发现问题依旧存在,请往下看
描述:我的工程中曾因为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
from person_detection.msg import position as PositionMsg
File "/home/passoni/wheeltec_robot_assist/src/person_detection/scripts/person_detection.py", line 13, in
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文件说明