import rospy ..._traceback (most recent call last">
当前位置:   article > 正文

ROS执行python文件遇到错误ModuleNotFoundError: No module named ‘yaml‘解决方法_traceback (most recent call last): file "/opt/ros/

traceback (most recent call last): file "/opt/ros/melodic/lib/python2.7/dist

       实现订阅者Subscriber的测试编程,执行命令:

$ rosrun learning_topic pose_subscriber.py

        遇到如下错误:

  1. Traceback (most recent call last):
  2.   File "/home/yue/catkin_ws/src/learning_topic/scripts/pose_subscriber.py", line 10, in <module>
  3.     import rospy
  4.   File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/__init__.py", line 47, in <module>
  5.     from std_msgs.msg import Header
  6.   File "/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
  7.     from ._Bool import *
  8.   File "/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/_Bool.py", line 6, in <module>
  9.     import genpy
  10.   File "/opt/ros/melodic/lib/python2.7/dist-packages/genpy/__init__.py", line 34, in <module>
  11.     from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
  12.   File "/opt/ros/melodic/lib/python2.7/dist-packages/genpy/message.py", line 48, in <module>
  13.     import yaml
  14. ModuleNotFoundError: No module named 'yaml'

解决方法:

        $ rosrun learning_topic pose_subscriber.py

        在上述命令行的基础上删除.py后缀,就可以了。

 

实验结果:删除.py后缀,可以看出程序执行正常。

        

$ rosrun learning_topic pose_subscriber

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/375490
推荐阅读
相关标签
  

闽ICP备14008679号