ROS2:导入错误:没有名为 genmsg 的模块

Ale*_*x44 3 python ros ros2

I starting with ROS2 which is currently in the alpha phase. While building the package ros1_bridge I got this error:

Traceback (most recent call last):
  File "bin/ros1_bridge_generate_factories", line 11, in <module>
    from ros1_bridge import generate_cpp
  File "/home/ros/ros2_ws/src/ros2/ros1_bridge/ros1_bridge/__init__.py", line 13, in <module>
    import genmsg
ImportError: No module named 'genmsg'
Run Code Online (Sandbox Code Playgroud)

This is quite strange. On the same computer I build the same code without any problem. The only thing that changed: I have installed ROS Kinetic.

I found out in synaptic that I have now two different packages of genmsg installed: python-genmsg and ros-kinetic-genmsg. The first one comes as dependency of ROS2 the second one with ROS. So may both are necessary. I think that is Python-stuff and I am not familiar with Python. What can I do to get it run again?

Ale*_*x44 5

当在同一台机器上为ROSROS2安装依赖项时会发生这种情况。尤其是包python-genmsgros-kinetic-genmsg. genmsg现在可以在这些地方找到:

  1. /opt/ros/kinetic/lib/python2.7/dist-packages
  2. /usr/lib/python2.7/dist-packages

这会给 Python 带来麻烦。就ros1_bridge应适合ROS Kinetic 而言,环境 Python 变量PYTHONPATH将设置为Kinetic变量:

export PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages/
Run Code Online (Sandbox Code Playgroud)

现在重新启动构建,构建现在运行......