ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost)

asked 2021-01-06 02:10:07 -0500

first-penguin gravatar image

Hi! When I built my program with catkin build, I got the following error:

File "/opt/ros/melodic/lib/python2.7/dist-packages/cv_bridge/", line 91, in encoding_to_cvtype2
    from cv_bridge.boost.cv_bridge_boost import getCvType
ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost)

After searching for the cause, I found that cv_bridge is built with python2 by default. My environment is as follows. ・ Virtualenv (python3.6) ・ ROS melodic ・ Jetson AGX xavier

I wanted to use cv_bridge with python3, so I used the link below to build cv_bridge with the following steps.

sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-kinetic-cv-bridge
mkdir catkin_ws
cd catkin_ws
source ~/virtualenv/jetson/bin/activate
catkin init
# Instruct catkin to set cmake variables
catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib/aarch64-linux-gnu/
# Instruct catkin to install built packages into install place. It is $CATKIN_WORKSPACE/install folder
catkin config --install
# Clone cv_bridge src
git clone src/vision_opencv
# Find version of cv_bridge in your repository
apt-cache show ros-kinetic-cv-bridge | grep Version
cd src/vision_opencv/
git checkout 1.13.0(maybe, I forgot)
cd ../../
# Build
catkin build cv_bridge
# Extend environment with new package
source install/setup.bash --extend

After performing this procedure, from cv_bridge.boost.cv_bridge_boost import getCvType no longer causes an error. After that, I put other nodes I created in catkin_ws and built it with catkin build. However, when I run it with roslauch, I get the following error:

RLException: [sample.launch] is neither a launch file in package [sample_proc] nor is [sample_proc] a launch file name

Running source devel/setup.bash does not eliminate this error. Do I need to do anything different if I use virtualenv?

The ROS_PACKAGE_PATH when building cv_bridge with python3 is as follows.

(jetson) nvidia@nvidia:~/catkin_ws$ echo $ROS_PACKAGE_PATH

By default, ROS_PACKAGE_PATH was as follows:

(jetson) nvidia@nvidia:~/catkin_ws$ echo $ROS_PACKAGE_PATH


edit retag flag offensive close merge delete


Hi. I am facing the same error. Could you please help me to figure it out? Python 3.6 Jetson TX2 Jetpack 4.5 Ubuntu 18.04

subarashi gravatar image subarashi  ( 2021-07-09 03:23:55 -0500 )edit