catkin_make install fails due to: "Import Error: no module named `yaml`"
When following along with the Beginner Tutorial, I arrive at creating Messages and Services. However when I call catkin_make install
inside the correct directory, I get the following error:
Traceback (most recent call last):
File "/opt/ros/kinetic/share/genpy/cmake/../../../lib/genpy/genmsg_py.py", line 44, in <module>
import genpy.generator
File "/opt/ros/kinetic/lib/python2.7/dist-packages/genpy/__init__.py", line 34, in <module>
from . message import Message, SerializationError, DeserializationError, MessageException, struct_I
File "/opt/ros/kinetic/lib/python2.7/dist-packages/genpy/message.py", line 44, in <module>
import yaml
ImportError: No module named 'yaml'
beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_py.dir/build.make:64: recipe for target '/home/ros/catkin_ws/devel/lib/python3/dist-packages/beginner_tutorials/msg/_Num.py' failed
make[2]: *** [/home/ros/catkin_ws/devel/lib/python3/dist-packages/beginner_tutorials/msg/_Num.py] Error 1
CMakeFiles/Makefile2:519: recipe for target 'beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_py.dir/all' failed
make[1]: *** [beginner_tutorials/CMakeFiles/beginner_tutorials_generate_messages_py.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make install -j1 -l1" failed
However yaml seems to be installed correctly, since I get no errors when using import yaml
in a python script. There seems to be something fishy going on with the different versions of python though, since I get the following output for my $PYTHONPATH
:
/home/ros/catkin_ws/devel/lib/python3/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages
Where there is cleary some conflict between python3 and python2.
I am using Ubuntu 16.04 with ROS:Kinetic and a Virtual Environment with Python 2.7.12 and pip gives me the following for pyyaml:
/home/.virtualenvs/ros/lib/python2.7/site-packages
whereas apt-get gives me
python-yaml is already the newest version (3.11-3build1)
Does anyone have any idea how to fix this?