📜  ImportError: 动态模块未定义模块导出函数 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:24.937000             🧑  作者: Mango

代码示例1
# NOTES: ROS Melodic -- Python3.7
# Solution is to build cv_bridge with python3.
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
catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.7m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.7m.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******

# 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
catkin build cv_bridge
# Extend environment with new package
source install/setup.bash --extend

# And you can test it with the following 
$ python3
Python 3.7.5 (default, Feb 23 2021, 13:22:40) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cv_bridge.boost.cv_bridge_boost import getCvType
>>> 

# Or add it to your bashrc file
source ~/catkin_workspace/install/setup.bash --extend