python3报错:importError: dynamic module does not define module export function (PyInit_cv_bridge_boost

1 在使用python3调用cv_bridge报错

1、在使用python3调用cv_bridge报错:importError: dynamic module does not define module export function (PyInit_cv_bridge_boost)

2、解决方式(参考

# `python-catkin-tools` is needed for catkin tool
# `python3-dev` and `python3-catkin-pkg-modules` is needed to build cv_bridge
# `python3-numpy` and `python3-yaml` is cv_bridge dependencies
# `ros-kinetic-cv-bridge` is needed to install a lot of cv_bridge deps. Probaply you already have it installed.
sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-melodic-cv-bridge
# Create catkin workspace
mkdir catkin_workspace
cd catkin_workspace
catkin init
# Instruct catkin to set cmake variables
# 这里根据你的python3具体版本修改
catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib/x86_64-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-melodic-cv-bridge | grep Version
    Version: 1.13.0-0bionic.20210505.032238
# Checkout right version in git repo. In our case it is 1.13.0
cd src/vision_opencv/
git checkout 1.13.0
cd ../../
# Build
# 编译的时候如果提示没有cmake,可以通过:python3 -m pip install cmake
catkin build cv_bridge
# Extend environment with new package
source install/setup.bash --extend

注意:

1、如果打开一个新的终端,需要再source一次,如果不想每次python3使用都source,就可以将其添加到~/.bashrc环境变量中

shl@zhihui-mint:~/tools/catkin_cv_bridge_ws$ source install/setup.bash --extend
shl@zhihui-mint:~/tools/catkin_cv_bridge_ws$ python3
Python 3.6.9 (default, Oct  8 2020, 12:12:24) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cv_bridge.boost.cv_bridge_boost import getCvType
>>> 

2、如果要用python2继续使用cv_bridge,就不需要source了!

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值