ROS2: ImportError: No module named genmsg
<p>I starting with <em>ROS2</em> which is currently in the alpha phase. While building the package <code>ros1_bridge</code> I got this error:</p>

<pre><code>Traceback (most recent call last):
  File "bin/ros1_bridge_generate_factories", line 11, in &lt;module&gt;
    from ros1_bridge import generate_cpp
  File "/home/ros/ros2_ws/src/ros2/ros1_bridge/ros1_bridge/__init__.py", line 13, in &lt;module&gt;
    import genmsg
ImportError: No module named 'genmsg'
</code></pre>

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

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

<p>Thanks in advance,<br>
Alex</p>

<p>This happens while dependencies installed for <em>ROS</em> and <em>ROS2</em> on the same
machine. Especially the package <code>python-genmsg</code> and <code>ros-kinetic-genmsg</code>.
<code>genmsg</code> can now found at these places:</p>

<ol>
<li>/opt/ros/kinetic/lib/python2.7/dist-packages</li>
<li>/usr/lib/python2.7/dist-packages</li>
</ol>

<p>This will bring Python run into trouble. In respect that <code>ros1_bridge</code> shall fit to <em>ROS Kinetic</em> the environment Python
variable <code>PYTHONPATH</code> will set to the <em>Kinetic</em> one:</p>

<pre><code>export PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages/
</code></pre>

<p>Now restart the build and the build runs now...</p>

python ros