Tag Archives: ImportError: No module named yaml

[Solved] rosrun import rospy Error: ImportError: No module named yaml

rosrun Error:

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

 

Reason: there are two versions of python locally
Check the current version: /usr/bin/python –version
Solution:

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

Importerror: no module named yaml solution [How to Solve]

problem : I got the “ImportError: No module named yaml ” error when I attempted  to install NLTK toolkit to my ubuntu system.

solution:

yaml library for python seems to not be installed on your system.

On ubuntu system just do a :

sudo apt-get install python-yaml

On windows

easy_install python-yaml

easy_install rosinstall

 

When installing under the window, it may not have its own installation easy_install, we need to install it manually

First download the easy_install installation package, download address:
http://pypi.python.org/pypi/setuptools

Find ez_setup.py on the page and download it and execute it

It is troublesome to download  PyYAML-3.10.win32-py2.7.exe directly