解决ROS和Anaconda的Python冲突问题的ROS知识

目录

1 问题提出

2 问题分析

3 改进方法

1 问题提出
开始编译一次工作空间,

$ catkin_make 它就报错了:

CMake Error at /opt/ros/noetic/share/catkin/cmake/empy.cmake:30 (message):
  Unable to find either executable 'empy' or Python module 'em'…  try
  installing the package 'python3-empy'

2 问题分析
在ubuntu系统中,存在两个python;python2.7和python3.8(注意这两个版本不可删除,否则OS系统瘫痪);又装了一个anaconda后,出现了第三个版本的python3.9.

        因此系统中三个版本python:

python2.7
python3.8
anaconda/lib/bin/python3.9
        他们的环境别名是:(/usr/bin中见到的软连接)

                python2、python3,python

        最近的ROS-noetic中,需要用python3,但无法用anaconda内的python3,因此,这里需要选python3.8,别名是python3

3 改进方法
        wiki上提到了这个问题:
        "对于ROS Melodic和早期版本的Python 3用户:注意,如果你从源代码构建ROS来实现Python 3的兼容性,并适当地设置您的系统(即:安装所有必需的ROS Python包的Python 3版本,例如catkin),

        那么在首次建立工作区后,在这个干净的catkin工作区中的第一次catkin_make命令必须是:

                $ catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3

        这将会配置catkin_make使用Python 3。

        以后执行编译就直接$ catkin_make了;因为首次catkin-make已经在CMakeList中设定好python路径;后边再编译就默认为此路径。

————————————————
 

可以解决自己遇到的问题:

catkin_make时出现错误提示如下:

catkin_make
Base path: /home/efsz/zmq_to_ros
Source space: /home/efsz/zmq_to_ros/src
Build space: /home/efsz/zmq_to_ros/build
Devel space: /home/efsz/zmq_to_ros/devel
Install space: /home/efsz/zmq_to_ros/install
Creating symlink "/home/efsz/zmq_to_ros/src/CMakeLists.txt" pointing to "/opt/ros/noetic/share/catkin/cmake/toplevel.cmake"
####
#### Running command: "cmake /home/efsz/zmq_to_ros/src -DCATKIN_DEVEL_PREFIX=/home/efsz/zmq_to_ros/devel -DCMAKE_INSTALL_PREFIX=/home/efsz/zmq_to_ros/install -G Unix Makefiles" in "/home/efsz/zmq_to_ros/build"
####
— The C compiler identification is GNU 9.4.0
— The CXX compiler identification is GNU 9.4.0
— Check for working C compiler: /usr/bin/cc
— Check for working C compiler: /usr/bin/cc — works
— Detecting C compiler ABI info
— Detecting C compiler ABI info – done
— Detecting C compile features
— Detecting C compile features – done
— Check for working CXX compiler: /usr/bin/c++
— Check for working CXX compiler: /usr/bin/c++ — works
— Detecting CXX compiler ABI info
— Detecting CXX compiler ABI info – done
— Detecting CXX compile features
— Detecting CXX compile features – done
— Using CATKIN_DEVEL_PREFIX: /home/efsz/zmq_to_ros/devel
— Using CMAKE_PREFIX_PATH: /opt/ros/noetic
— This workspace overlays: /opt/ros/noetic
— Found PythonInterp: /home/efsz/anaconda3/bin/python3 (found suitable version "3.9.13", minimum required is "3") 
— Using PYTHON_EXECUTABLE: /home/efsz/anaconda3/bin/python3
— Using Debian Python package layout
— Could NOT find PY_em (missing: PY_EM) 
CMake Error at /opt/ros/noetic/share/catkin/cmake/empy.cmake:30 (message):
  Unable to find either executable 'empy' or Python module 'em'…  try
  installing the package 'python3-empy'
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/all.cmake:164 (include)
  /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:58 (find_package)

— Configuring incomplete, errors occurred!
See also "/home/efsz/zmq_to_ros/build/CMakeFiles/CMakeOutput.log".
Invoking "cmake" failed
翻译:

柔荑花
基本路径:/home/efsz/zmq_to_ros
源码空间:/home/efsz/zmq_to_ros/src
构建空间:/home/efsz/zmq_to_ros/build
开发空间:/home/efsz/zmq_to_ros/devel
安装空间:/home/efsz/zmq_to_ros/install
创建指向“/opt/ros/noetic/share/catkin/cmake/toplevel.cmake”的符号链接“/home/efsz/zmq_to_ros/src/CMakeLists.txt”
####
#### 运行命令:“cmake /home/efsz/zmq_to_ros/src -DCATKIN_DEVEL_PREFIX=/home/efsz/zmq_to_ros/devel -DCMAKE_INSTALL_PREFIX=/home/efsz/zmq_to_ros/install -G Unix Makefiles”在“/home/efsz /zmq_to_ros/build"
####
— C编译器标识为GNU 9.4.0
— CXX编译器标识为GNU 9.4.0
— 检查工作的 C 编译器:/usr/bin/cc
— 检查工作的 C 编译器:/usr/bin/cc — 工作
— 检测 C 编译器 ABI 信息
— 检测 C 编译器 ABI 信息 – 完成
— 检测 C 编译特性
— 检测 C 编译特性 – 完成
— 检查工作的 CXX 编译器:/usr/bin/c++
— 检查工作的 CXX 编译器:/usr/bin/c++ — 工作
— 检测 CXX 编译器 ABI 信息
— 检测 CXX 编译器 ABI 信息 – 完成
— 检测 CXX 编译特性
— 检测 CXX 编译特性 – 完成
— 使用 CATKIN_DEVEL_PREFIX: /home/efsz/zmq_to_ros/devel
— 使用 CMAKE_PREFIX_PATH: /opt/ros/noetic
— 这个工作区覆盖:/opt/ros/noetic
— 找到 PythonInterp: /home/efsz/anaconda3/bin/python3(找到合适的版本“3.9.13”,最低要求是“3”)
— 使用 PYTHON_EXECUTABLE: /home/efsz/anaconda3/bin/python3
— 使用 Debian Python 包布局
— 找不到 PY_em(缺少:PY_EM)
/opt/ros/noetic/share/catkin/cmake/empy.cmake:30 处的 CMake 错误(消息):
   无法找到可执行文件“empy”或 Python 模块“em”…尝试
   安装软件包“python3-empy”
调用堆栈(最近的调用在前):
   /opt/ros/noetic/share/catkin/cmake/all.cmake:164(包括)
   /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20(包括)
   CMakeLists.txt:58 (find_package)

— 配置不完整,出现错误!
另见“/home/efsz/zmq_to_ros/build/CMakeFiles/CMakeOutput.log”。
调用“cmake”失败

————————————————————————————————————————

核心内容:

ERROR: Could not find a version that satisfies the requirement python3-empy (from versions: none)
ERROR: No matching distribution found for python3-empy
翻译:

错误:找不到满足 python3-empy 要求的版本(来自版本:无)
错误:找不到与 python3-empy 匹配的分布

按教程修改为Python3,也就是系统自带的Python3.8,之后再编译就成功了(catkin_make)

物联沃分享整理
物联沃-IOTWORD物联网 » 解决ROS和Anaconda的Python冲突问题的ROS知识

发表评论