ModuleNotFoundError: No module named 'yaml'
Hello!
I am only starting to learn ROS by attending Udemy course on it. Recently I have encountered a problem, when I try to run simple talker example using command:
rosrun ros_essentials_cpp talker.py
I receive an error:
(base) ➜ catkin_ws rosrun ros_essentials_cpp talker.py
Traceback (most recent call last):
File "/mnt/c/Users/daniu/Documents/Projects/ROS/catkin_ws/src/ros_essentials_cpp/src/topic01_basics/talker_listener/scripts/talker.py", line 3, in <module>
import rospy
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/__init__.py", line 47, in <module>
from std_msgs.msg import Header
File "/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
from ._Bool import *
File "/opt/ros/melodic/lib/python2.7/dist-packages/std_msgs/msg/_Bool.py", line 5, in <module>
import genpy
File "/opt/ros/melodic/lib/python2.7/dist-packages/genpy/__init__.py", line 34, in <module>
from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
File "/opt/ros/melodic/lib/python2.7/dist-packages/genpy/message.py", line 44, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
I tried to install yaml
python2.7 -m pip install pyyaml
Installation was successful, but it does not change anything
Previously I had no problems running ROS code (this talker.py too), but I have made a pause in my learning and after return, nothing is working
I am using WSL (Ubuntu 18.04 bionic)
Thank you for your help!
Do you have any other Python interpreters / IDEs / runtime environments installed? Anaconda by any chance?
What is the output of
which python
andpython -c 'import yaml'
?Yes, I do, I have an anaconda and my default Python is Python 3
Is it a problem in their conflict? I was thinking about it, but did't find a way to resolve this
Yes, having Anaconda installed and having Python 3 the default is the cause of your problems.
There are many Q&As about this on this site. I suggest you search for them using Google (append
site:answers.ros.org
to your query).