在学习仿真的时候跑TurtleBot3,执行键盘控制机器人移动
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
报错:
import yaml
ImportError: No module named yaml
[turtlebot3_teleop_keyboard-1] process has died [pid 31632, exit code 1, cmd /home/ubuntu/ros_ws/src/turtlebot3/turtlebot3_teleop/nodes/turtlebot3_teleop_key __name:=turtlebot3_teleop_keyboard __log:=/home/ubuntu/.ros/log/fb54bd86-a1da-11ed-af07-a99953384ef4/turtlebot3_teleop_keyboard-1.log].
log file: /home/ubuntu/.ros/log/fb54bd86-a1da-11ed-af07-a99953384ef4/turtlebot3_teleop_keyboard-1*.log
百度说导入pyyaml,出现新的错误:类似这个
解决办法:参考:Ubuntu20.04运行python文件时报错No module named ‘rospkg‘的解决方法_慕羽★的博客-CSDN博客
一般来说,并不是真的缺少rospkg,而是系统中存在多个python版本导致的混乱
cd /usr/bin
sudo ln -s /usr/bin/python3.8 python
若是在运行上面那条指令时,报错名为python文件已存在,则输入以下指令删除原有的名为python的文件然后就可以运行控制小车跑仿真了
sudo rm python