Unicode error being thrown when trying to make rosserial module
Question: I've recently started a project in using ROS to publish events using an
arduino from the rosserial module. Whenever I invoke catkin_make on the
workspace I make it through many of the packages in rosserial, but get errors
when trying to make TopicInfo.msg, Log.msg, and rosserial_arduino. Below is
the thrown errors and the problems which are referencing unicode hashing
problems. I've tried repathing and sourcing to the correct areas but nothing
seems to help. Anyone have suggestions? Also I'm running Arch linux with ROS
Hypdro.

    
    
    Generating Lisp code from rosserial_msgs/TopicInfo.msg
    Traceback (most recent call last):
     File "/opt/ros/hydro/share/gencpp/cmake/../../../lib/gencpp/gen_cpp.py", line 41, in    <module>
        import genmsg.template_tools
     File "/opt/ros/hydro/lib/python2.7/site-packages/genmsg/template_tools.py", line 74
        raise RuntimeError, "Template file %s not found in template dir %s" % (template_file_name, template_dir)
                          ^
    SyntaxError: invalid syntax
        rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_cpp.dir/build.make:59: recipe for target '/home/jared/Documents/AdvancedRoboticsArm/catkin_ws/devel/include/rosserial_msgs/TopicInfo.h' failed
    make[2]: *** [/home/jared/Documents/AdvancedRoboticsArm/catkin_ws/devel/include/rosserial_msgs/TopicInfo.h] Error 1
    CMakeFiles/Makefile2:337: recipe for target 'rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_cpp.dir/all' failed
    make[1]: *** [rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_cpp.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....
    [ 20%] Traceback (most recent call last):
      File "/opt/ros/hydro/lib/python2.7/site-packages/genlisp/genlisp_main.py", line 71, in genmain
        retcode = generate_msg(options.package, args[1:], options.outdir, search_path)
    Generating Lisp code from rosserial_msgs/Log.msg
      File "/opt/ros/hydro/lib/python2.7/site-packages/genlisp/generate.py", line 720, in generate_msg
        generate_msg_from_spec(msg_context, spec, search_path, out_dir, pkg)
      File "/opt/ros/hydro/lib/python2.7/site-packages/genlisp/generate.py", line 770, in generate_msg_from_spec
        write_md5sum(s, msg_context, spec)
      File "/opt/ros/hydro/lib/python2.7/site-packages/genlisp/generate.py", line 591, in write_md5sum
        md5sum = genmsg.compute_md5(msg_context, parent or spec)
      File "/opt/ros/hydro/lib/python2.7/site-packages/genmsg/gentools.py", line 119, in compute_md5
        return _compute_hash(msg_context, spec, hashlib.md5())
      File "/opt/ros/hydro/lib/python2.7/site-packages/genmsg/gentools.py", line 103, in _compute_hash
        hash.update(compute_md5_text(msg_context, spec))
    TypeError: Unicode-objects must be encoded before hashing
    ERROR:  Unicode-objects must be encoded before hashing
    rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_lisp.dir/build.make:58: recipe for target '/home/jared/Documents/AdvancedRoboticsArm/catkin_ws/devel/share/common-lisp/ros/rosserial_msgs/msg/TopicInfo.lisp' failed
    make[2]: *** [/home/jared/Documents/AdvancedRoboticsArm/catkin_ws/devel/share/common-lisp/ros/rosserial_msgs/msg/TopicInfo.lisp] Error 3
    make[2]: *** Waiting for unfinished jobs....
    [ 25%] Traceback (most recent call last):
      File "/opt/ros/hydro/lib/python2.7/site-packages/genpy/generator.py", line 965, in generate_messages
        outfile = self.generate(msg_context, full_type, f, outdir, search_path) #actual generation
      File "/opt/ros/hydro/lib/python2.7/site-packages/genpy/generator.py", line 946, in generate
        for l in self.generator_fn(msg_context, spec, search_path):
      File "/opt/ros/hydro/lib/python2.7/site-packages/genpy/generator.py", line 885, in srv_generator
        for l in msg_generator(msg_context, mspec, search_path):
      File "/opt/ros/hydro/lib/python2.7/site-packages/genpy/generator.py", line 736, in msg_generator
        md5sum = genmsg.compute_md5(msg_context, spec)
      File "/opt/ros/hydro/lib/python2.7/site-packages/genmsg/gentools.py", line 119, in compute_md5
        return _compute_hash(msg_context, spec, hashlib.md5())
      File "/opt/ros/hydro/lib/python2.7/site-packages/genmsg/gentools.py", line 103, in _compute_hash
        hash.update(compute_md5_text(msg_context, spec))
    TypeError: Unicode-objects must be encoded before hashing
    
    ERROR: Unable to generate services for package 'rosserial_msgs': while processing '/home/jared/Documents/AdvancedRoboticsArm/catkin_ws/src/rosserial/rosserial_msgs/srv/RequestParam.srv': Unicode-objects must be encoded before hashing
    
    Generating Python srv __init__.py for rosserial_arduino
    rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_py.dir/build.make:78: recipe for target '/home/jared/Documents/AdvancedRoboticsArm/catkin_ws/devel/lib/python3.4/site-packages/rosserial_msgs/srv/_RequestParam.py' failed
    make[2]: *** [/home/jared/Documents/AdvancedRoboticsArm/catkin_ws/devel/lib/python3.4/site-packages/rosserial_msgs/srv/_RequestParam.py] Error 1
    CMakeFiles/Makefile2:399: recipe for target 'rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_py.dir/all' failed
    make[1]: *** [rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_py.dir/all] Error 2
    Traceback (most recent call last):
      File "/opt/ros/hydro/lib/python2.7/site-packages/genlisp/genlisp_main.py", line 71, in genmain
        retcode = generate_msg(options.package, args[1:], options.outdir, search_path)
      File "/opt/ros/hydro/lib/python2.7/site-packages/genlisp/generate.py", line 720, in generate_msg
        generate_msg_from_spec(msg_context, spec, search_path, out_dir, pkg)
      File "/opt/ros/hydro/lib/python2.7/site-packages/genlisp/generate.py", line 770, in generate_msg_from_spec
        write_md5sum(s, msg_context, spec)
      File "/opt/ros/hydro/lib/python2.7/site-packages/genlisp/generate.py", line 591, in write_md5sum
        md5sum = genmsg.compute_md5(msg_context, parent or spec)
      File "/opt/ros/hydro/lib/python2.7/site-packages/genmsg/gentools.py", line 119, in compute_md5
        return _compute_hash(msg_context, spec, hashlib.md5())
      File "/opt/ros/hydro/lib/python2.7/site-packages/genmsg/gentools.py", line 103, in _compute_hash
        hash.update(compute_md5_text(msg_context, spec))
    TypeError: Unicode-objects must be encoded before hashing
    ERROR:  Unicode-objects must be encoded before hashing
    rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_lisp.dir/build.make:64: recipe for target '/home/jared/Documents/AdvancedRoboticsArm/catkin_ws/devel/share/common-lisp/ros/rosserial_msgs/msg/Log.lisp' failed
    make[2]: *** [/home/jared/Documents/AdvancedRoboticsArm/catkin_ws/devel/share/common-lisp/ros/rosserial_msgs/msg/Log.lisp] Error 3
    CMakeFiles/Makefile2:368: recipe for target 'rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_lisp.dir/all' failed
    make[1]: *** [rosserial/rosserial_msgs/CMakeFiles/rosserial_msgs_generate_messages_lisp.dir/all] Error 2
    [ 33%] Built target rosserial_arduino_generate_messages_py
    Makefile:126: recipe for target 'all' failed
    make: *** [all] Error 2
    Invoking "make" failed
    

Any input would be helpful. Thanks!


Answer: Your SyntaxError Exception for the comma in `raise RuntimeError, ...` suggests
the Python interpreter is actually Python 3 despite your lib path contains
Python 2.7 libs.

Double check your paths and ensure you're running Python 2.7

