ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Error when trying to run a python node built with the --symlink-install option

asked 2018-08-27 23:03:52 -0600

Marc Testier gravatar image

updated 2018-08-29 01:01:45 -0600


I'm using ROS2 Bouncy, built from source on Ubuntu 18.04 and I'm trying to build a python node using colcon build --symlink-install but when running the node, it gives me an error ModuleNotFoundError: No module named 'src.client'. When I build without the --symlink-install, it works but then I have to build every time I modify the python file...

I'm probably doing something wrong because yesterday, it worked... I could build with the --symlink-install option and could modify the python file without having to build again. I cleaned the install and build folder and now it doesn't work.

The code can be found here : There is 3 packages : the server, the client and an interface package with just 2 srv files. You can run the full thing by running : ros2 run kone_open_opc_server_simu kone_simu then ros2 run kone_open_opc_client kone_client

Here is the folder structure :

├── client
│   ├── package.xml
│   ├── resource
│   │   └── opc_client
│   ├── setup.cfg
│   ├──
│   └── src
│       ├──
│       └──

And the :

from setuptools import find_packages
from setuptools import setup

package_name = 'opc_client'

            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
    author='Marc-Antoine Testier',
    maintainer='Marc-Antoine Testier',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python',
        'Topic :: Software Development',
    license='Apache License, Version 2.0',
        'console_scripts': [
            'client = src.client:main',

The python file :

#!/usr/bin/env python

import rclpy
from rclpy.node import Node

class OpcClient(Node):

    def __init__(self):

        # AGV Identifier
        self.simu = 1
        # Simulation bool
        self.agvID = "AGV1"

def main(args=None):

    node = OpcClient()


    # Destroy the node explicitly
    # (optional - Done automatically when node is garbage collected)

if __name__ == '__main__':

The package.xml just in case :

<?xml version="1.0"?>
<package format="2">
  <description>OPC client</description>
  <maintainer email="">Marc-Antoine Testier</maintainer>
  <author email="">Marc-Antoine Testier</author>
  <license>Apache License 2.0</license>



edit retag flag offensive close merge delete


I just tried it with the example shown and colcon build --symlink-install. After sourcing install/setup.bash I was able to call client without a problem. Maybe check that you have the latest version of colcon (e.g. with colcon version-check).

Dirk Thomas gravatar image Dirk Thomas  ( 2018-08-28 09:55:31 -0600 )edit

Colcon is up-to date, but since you don't have the problem, it's probably my fault, might have forgotten a step during the installation. What bugs me is that I can still directly source the package in the install folder... I'll try on another machine with a clean installation and update the post.

Marc Testier gravatar image Marc Testier  ( 2018-08-28 21:20:12 -0600 )edit

Updated the post with a github link to the code. I have the same problem when using it with another machine with ros2 bouncy from the debian packages. The server package which has a similar structure works but not the client one... still have to source the package.bash in install/<pkg>/share/<pkg>

Marc Testier gravatar image Marc Testier  ( 2018-08-29 01:04:22 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-08-28 01:11:58 -0600

Marc Testier gravatar image

updated 2018-08-28 03:18:25 -0600

Ok, I fixed it, the name of the folder needs to be the same as the name of the package... Don't know if we just can't have different names of if I need to change some configs somewhere but since I'm new to ROS2 + python, I'm just going to rename the folder (and it's the best practice anyway).

It probably worked before because of some cached files.

EDIT: Nevermind, it only temporary worked. I opened another terminal, sourced and the problem appeared again. I found that if I source the file in the install folder : install/opc_client/share/opc_client/package.bash then it works...

edit flag offensive delete link more


You might want to report this over at the issue tracker of one of the repositories in I'm not sure which one that should be though ..

Perhaps @Dirk Thomas can help.

gvdhoorn gravatar image gvdhoorn  ( 2018-08-28 03:20:05 -0600 )edit

Question Tools



Asked: 2018-08-27 23:03:52 -0600

Seen: 966 times

Last updated: Aug 29 '18