Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
923 views
in Technique[技术] by (71.8m points)

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

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

File "/opt/ros/melodic/lib/python2.7/dist-packages/cv_bridge/core.py", 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. Unable to use cv_bridge with ROS Kinetic and Python3

sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-kinetic-cv-bridge
# Create catkin workspace
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/libpython3.6m.so
# Instruct catkin to install built packages into install place. It is $CATKIN_WORKSPACE/install folder
catkin config --install
# Clone cv_bridge src
git clone https://github.com/ros-perception/vision_opencv.git 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.

The ROS_PACKAGE_PATH when building cv_bridge with python3 is as follows.

(jetson) nvidia@nvidia:~/catkin_ws$ echo $ROS_PACKAGE_PATH
/home/nvidia/catkin_ws/install/share:/opt/ros/melodic/share

By default, ROS_PACKAGE_PATH was as follows:

(jetson) nvidia@nvidia:~/catkin_ws$ echo $ROS_PACKAGE_PATH
/opt/ros/melodic/share:/home/nvidia/catkin_ws/src/vision_opencv/cv_bridge:/home/nvidia/catkin_ws/src/ddynamic_reconfigure:/home/nvidia/catkin_ws/src/vision_opencv/image_geometry:/home/nvidia/catkin_ws/src/vision_opencv/opencv_tests:/home/nvidia/catkin_ws/src/pose_msgs:/home/nvidia/catkin_ws/src/output:/home/nvidia/catkin_ws/src/pose_check_proc:/home/nvidia/catkin_ws/src/post_proc:/home/nvidia/catkin_ws/src/realsense-ros/realsense2_camera:/home/nvidia/catkin_ws/src/realsense-ros/realsense2_description:/home/nvidia/catkin_ws/src/set_datetime_proc:/home/nvidia/catkin_ws/src/vision_opencv/vision_opencv

Do I need to do anything different if I use virtualenv? Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...