Ask Your Question
0

ModuleNotFoundError: No module named 'yaml'

asked 2019-07-07 01:46:22 -0500

beliavskij gravatar image

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!

edit retag flag offensive close merge delete

Comments

Do you have any other Python interpreters / IDEs / runtime environments installed? Anaconda by any chance?

What is the output of which python and python -c 'import yaml'?

gvdhoorn gravatar imagegvdhoorn ( 2019-07-07 09:03:15 -0500 )edit

Yes, I do, I have an anaconda and my default Python is Python 3

(base) ➜  ~ python --version
Python 3.7.1

(base) ➜  ~ which python
/home/belia/miniconda3/bin/python

(base) ➜  ~ python -c 'import yaml'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'yaml'

Is it a problem in their conflict? I was thinking about it, but did't find a way to resolve this

beliavskij gravatar imagebeliavskij ( 2019-07-07 23:21:38 -0500 )edit

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).

gvdhoorn gravatar imagegvdhoorn ( 2019-07-08 02:36:51 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-07-08 11:37:00 -0500

beliavskij gravatar image

Yes, I have found a solution that helped, it is described in this answer Using souce deactivate let my run the code Thank you

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-07-07 01:46:22 -0500

Seen: 177 times

Last updated: Jul 08