ros2编译python环境不匹配

solution_zoo common dir:
-- Found ament_cmake_auto: 0.9.11 (/opt/ros/foxy/share/ament_cmake_auto/cmake)
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find PythonInterp: Found unsuitable version "2.7.18", but
  required is at least "3" (found /usr/bin/python)

Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:391 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindPythonInterp.cmake:169 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /opt/ros/foxy/share/ament_cmake_core/cmake/core/python.cmake:22 (find_package)
  /opt/ros/foxy/share/ament_cmake_core/cmake/core/all.cmake:53 (include)
  /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_core-extras.cmake:17 (include)
  /opt/ros/foxy/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41 (include)
  /opt/ros/foxy/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
  /opt/ros/foxy/share/ament_cmake/cmake/ament_cmakeConfig.cmake:41 (include)
  /opt/ros/foxy/share/ament_cmake_auto/cmake/ament_cmake_auto-extras.cmake:17 (find_package)
  /opt/ros/foxy/share/ament_cmake_auto/cmake/ament_cmake_autoConfig.cmake:41 (include)
  solutionzoo/CMakeLists.txt:85 (find_package)

ros2环境配置python环境:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2
 

继续编译会发现c++的配置全部都报错了:

/usr/include/c++/9/ctime:64:11: error: ‘::clock’ has not been declared
   64 |   using ::clock;
      |           ^~~~~
/usr/include/c++/9/ctime:65:11: error: ‘::difftime’ has not been declared
   65 |   using ::difftime;
      |           ^~~~~~~~
/usr/include/c++/9/ctime:66:11: error: ‘::mktime’ has not been declared
   66 |   using ::mktime;
      |           ^~~~~~
/usr/include/c++/9/ctime:67:11: error: ‘::time’ has not been declared
   67 |   using ::time;
      |           ^~~~
/usr/include/c++/9/ctime:68:11: error: ‘::asctime’ has not been declared
   68 |   using ::asctime;
      |           ^~~~~~~
/usr/include/c++/9/ctime:69:11: error: ‘::ctime’ has not been declared
   69 |   using ::ctime;
      |           ^~~~~
/usr/include/c++/9/ctime:70:11: error: ‘::gmtime’ has not been declared
   70 |   using ::gmtime;
      |           ^~~~~~
/usr/include/c++/9/ctime:71:11: error: ‘::localtime’ has not been declared
   71 |   using ::localtime;
      |           ^~~~~~~~~
/usr/include/c++/9/ctime:72:11: error: ‘::strftime’ has not been declared
   72 |   using ::strftime;
      |           ^~~~~~~~

添加的模块代码,ros1需要C++11支持,ros2需要C++14支持

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ROS Noetic 版本中,Python 环境的配置方式与 ROS Melodic 版本有所不同。以下是在 Ubuntu 系统上配置 ROS Noetic 的 Python 环境的步骤: 1. 安装 ROS Noetic:可以参考 ROS Noetic 官方网站的安装教程,选择适合自己系统版本的 ROS Noetic 安装包,并按照提示进行安装。 2. 安装 Python 虚拟环境:为了避免不同的 Python 程序之间互相干扰,建议使用 Python 虚拟环境来进行开发。可以通过以下命令安装 Python 虚拟环境: ``` sudo apt-get install python3-venv ``` 3. 创建虚拟环境:在安装了 Python 虚拟环境后,可以通过以下命令创建一个新的虚拟环境: ``` python3 -m venv ~/venv ``` 这里将虚拟环境命名为 `venv`,可以根据个人需要进行命名。 4. 激活虚拟环境:创建完成后,需要激活虚拟环境,以便在虚拟环境中安装 ROS Noetic 的 Python 包。可以通过以下命令激活虚拟环境: ``` source ~/venv/bin/activate ``` 5. 安装 ROS Noetic 的 Python 包:在激活虚拟环境后,可以通过以下命令安装 ROS Noetic 的 Python 包: ``` sudo apt-get install python3-ros-noetic ``` 安装完成后,就可以在虚拟环境中使用 rospy、rospy_tutorials 等 ROSPython 包了。 6. 退出虚拟环境:当需要退出虚拟环境时,可以通过以下命令退出: ``` deactivate ``` 这样就完成了 ROS Noetic 的 Python 环境配置。可以在虚拟环境中使用 pip 等工具安装其他 Python 包,进行 ROSPython 编程。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值