rosrun import rospy报错


rosrun 报错

Traceback (most recent call last):
File "/home/ving/catkin_ws/src/hello_tutorial/src/hello.py", line 3, in
import rospy
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/__init__.py", line 47, in
from std_msgs.msg import Header
File "/opt/ros/noetic/lib/python3/dist-packages/std_msgs/msg/__init__.py", line 1, in
from ._Bool import *
File "/opt/ros/noetic/lib/python3/dist-packages/std_msgs/msg/_Bool.py", line 6, in
import genpy
File "/opt/ros/noetic/lib/python3/dist-packages/genpy/__init__.py", line 34, in
from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
File "/opt/ros/noetic/lib/python3/dist-packages/genpy/message.py", line 48, in
import yaml
ImportError: No module named yaml

原因:本地有两个版本的python

查看当前版本:/usr/bin/python --version

解决办法:

sudo ln -sf /usr/bin/python3 /usr/local/bin/python
logo
ROS