Running python3 script in ROS Kinetic

asked 2018-03-14 09:59:41 -0600

Stef gravatar image

updated 2018-03-14 14:19:31 -0600

I'm new to ROS and I'm having a problem with using a python3 script in ROS. I have a specific library that's only compatible with Python3 and I need a ROS Subscriber to use that library. I can't figure this out. Can someone explain me how I should do this?

UPDATE The error which I receive when I start my listener with "python3 listener.py"

Traceback (most recent call last):
  File "listener.py", line 1, in <module>
    import rospy
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/__init__.py", line 47, in <module>
    from std_msgs.msg import Header
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/std_msgs/msg/__init__.py", line 1, in <module>
    from ._Bool import *
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/std_msgs/msg/_Bool.py", line 5, in <module>
    import genpy
  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'
edit retag flag offensive close merge delete

Comments

What kind of problem you get when you run a python node. (Subscriber)

Gayan Brahmanage gravatar imageGayan Brahmanage ( 2018-03-14 12:22:07 -0600 )edit

I've updated my post :)

Stef gravatar imageStef ( 2018-03-14 14:19:40 -0600 )edit

Running Python3 code in Kinetic is very difficult. Your specific problem looks like you need to install the python3-yaml package. After that, there will be some other similar problem.

joq gravatar imagejoq ( 2018-03-15 12:16:13 -0600 )edit