from cv_bridge.boost.cv_bridge_boost import getCvType 又名ros python3 opencv 乱七八糟的问题之一

1. from cv_bridge.boost.cv_bridge_boost import getCvType
ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost)
原因:需要在python3下编译 cv_bridge

解决办法:

1.建立工作空间

mkdir -p catkin_workspace/src

cd catkin_workspace

2.设置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

(根据自己的版本修改 python 会出版本号)

3.下载cv_bridge

git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv

https://github.com/ros-perception/vision_opencv/releases/tag/1.12.8

apt-cache show ros-melodic-cv-bridge | grep Version

查看自己对应的版本

可以输入/releases 找对应版本下载,我下载的是vision_opencv-1.12.8.

放入catkin_workspace/src下,然后回到 catkin_workspace 下catkin_make

4.可能还会遇到的问题.

4.1

boost (missing python3) Found version ...

这个是缺乏python3 环境下的boost

编译boost

(1) 去boost官网 https://www.boost.org/ 下载较新版本的boost,如boost_1_58_0.zip.
(2) 解压: unzip boost_1_71_0.zip
(3) 进入boost_1_71_0, 执行如下命令:
    (a) ./bootstrap.sh --with-libraries=all --with-toolset=gcc
    (b) ./b2
    (c) sudo ./b2 install
    (d) sudo ldconfig
(4) 编译成功后可以在默认编译路径/usr/local/lib下找到相关的libboost*.so, boost在/usr/local/include/boost.
4.2解决ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'的方法

pip install --upgrade numpy 

5.参考文献

https://stackoverflow.com/questions/49221565/unable-to-use-cv-bridge-with-ros-kinetic-and-python3?rq=1

!!!    https://blog.csdn.net/weixin_42675603/article/details/107785376

https://blog.csdn.net/qq_44876051/article/details/112370423

boost https://blog.csdn.net/zsf10220208/article/details/102571611

numpy tensorflow不匹配 https://blog.csdn.net/lizzy05/article/details/102482464

猜你喜欢

转载自blog.csdn.net/qq_40297851/article/details/114396439