当前位置: 首页 > news >正文

兰陵建设局网站WordPress判断文章形式

兰陵建设局网站,WordPress判断文章形式,wordpress 不用主题,公众号开发运营在机器人操作系统(ROS)的开发过程中,构建工作空间时遇到各种依赖性问题是常见的挑战之一。尤其是在多Python环境共存的情况下,环境变量的冲突往往导致诸如缺少empy模块等错误。本文将详细介绍在ROS Noetic与Anaconda Python环境共…

在机器人操作系统(ROS)的开发过程中,构建工作空间时遇到各种依赖性问题是常见的挑战之一。尤其是在多Python环境共存的情况下,环境变量的冲突往往导致诸如缺少empy模块等错误。本文将详细介绍在ROS Noetic与Anaconda Python环境共存的情况下,如何通过调整环境变量优先级来解决Catkin构建失败的问题。

一、引言

随着机器人技术的发展,ROS(Robot Operating System)已成为机器人软件开发的标准框架。然而,开发过程中涉及多种工具和依赖库,尤其是Python环境的配置,常常成为潜在的障碍。特别是在系统Python与Anaconda等第三方Python环境共存时,环境变量的优先级可能导致ROS无法正确找到所需的模块,如empy,从而导致Catkin构建失败。
本文将以一个实际案例为基础,深入探讨在环境冲突情况下如何调整环境变量优先级,确保ROS的正常构建与运行。通过系统化的步骤和详尽的解释,帮助开发者快速定位并解决类似问题,提升开发效率

二、问题描述

在尝试使用Catkin构建ROS工作空间时,系统报出如下错误信息:

sunshine@sunshine:~/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws$ catkin_make
Base path: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws
Source space: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/src
Build space: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/build
Devel space: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/devel
Install space: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/install
####
#### Running command: "cmake /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/src -DCATKIN_DEVEL_PREFIX=/home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/devel -DCMAKE_INSTALL_PREFIX=/home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/install -G Unix Makefiles" in "/home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/noetic
-- This workspace overlays: /opt/ros/noetic
-- Using PYTHON_EXECUTABLE: /home/sunshine/SoftWare/Anaconda/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'...  tryinstalling 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:4 (find_package)-- Configuring incomplete, errors occurred!
See also "/home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/build/CMakeFiles/CMakeOutput.log".
Invoking "cmake" failed

经过检查,系统中并未找到empy模块,且即便通过apt-get安装了python3-empy,问题依旧存在。进一步排查发现,当前使用的是Anaconda的Python环境,而ROS Noetic期望使用系统自带的Python环境。这导致python3-empy安装在系统Python下,而Anaconda的Python环境无法识别该模块,进而引发构建失败

三 解决方案

1、确认当前Python环境

首先,确认当前系统使用的Python环境以及empy模块的安装情况

which python3
python3 -c "import em"

如果which python3输出的是Anaconda的路径(如/home/sunshine/SoftWare/Anaconda/bin/python3),且import em报错ModuleNotFoundError: No module named ‘em’,则说明当前Python环境无法识别empy模块

2、安装empy模块

由于ROS Noetic与系统Python环境高度集成,推荐使用系统包管理器安装empy

sudo apt-get update
sudo apt-get install python3-empy

安装完成后,验证安装是否成功:

which empy
python3 -c "import em"

理想情况下,which empy应返回/usr/bin/empy,且import em不应再报错

三 优先使用系统的Python环境

为了确保ROS使用系统的Python环境,可以通过临时调整PATH环境变量,使系统的Python和empy优先于Anaconda的环境。
在当前终端会话中,运行以下命令:

export PATH=/usr/bin:$PATH

解释:该命令将系统的/usr/bin目录添加到PATH的最前面,确保系统的Python和empy被优先调用。

验证调整是否生效

which python3
# 应输出 /usr/bin/python3which empy
# 应输出 /usr/bin/empypython3 -c "import em"
# 无错误输出

四、重新构建Catkin工作空间

(base) sunshine@sunshine:~/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws$ export PATH=/usr/bin:$PATH
(base) sunshine@sunshine:~/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws$ catkin_make
Base path: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws
Source space: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/src
Build space: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/build
Devel space: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/devel
Install space: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/install
####
#### Running command: "cmake /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/src -DCATKIN_DEVEL_PREFIX=/home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/devel -DCMAKE_INSTALL_PREFIX=/home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/install -G Unix Makefiles" in "/home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/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/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/noetic
-- This workspace overlays: /opt/ros/noetic
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Found PY_em: /usr/lib/python3/dist-packages/em.py  
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/build/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python3 (found version "3.8.10") 
-- Found Threads: TRUE  
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.10
-- BUILD_SHARED_LIBS is on
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/build
####
#### Running command: "make -j24 -l24" in "/home/sunshine/Instrument/WitHighModbus_HWT9073485/ROS/wit/wit_ros_ws/build"
####

构建完成!!

四 长期解决方案

如果频繁需要在Anaconda和系统Python环境之间切换,建议采用以下长期解决方案

1、创建独立的终端会话

在需要构建ROS工作空间时,开启一个不激活Anaconda环境的新终端,确保使用系统的Python环境

2、 使用虚拟环境

为ROS创建一个专用的Python虚拟环境,隔离其依赖:

python3 -m venv ros_env
source ros_env/bin/activate
pip install empy

在此环境中构建ROS工作空间,避免与其他Python项目的依赖冲突。

3、修改Anaconda的激活脚本

在激活Anaconda环境后,手动将系统的/usr/bin添加回PATH的优先位置

conda activate your_env_name
export PATH=/usr/bin:$PATH

这样可以确保在使用Anaconda环境的同时,系统的Python和empy依然优先可用。

五、总结

在多Python环境共存的系统中,确保ROS使用系统的Python环境是避免依赖性问题的关键。通过临时调整PATH环境变量,可以快速解决缺少empy模块导致的Catkin构建失败问题。然而,为了长期稳定地开发ROS项目,建议采用独立的终端会话或虚拟环境,确保ROS与其他Python项目的依赖隔离。这不仅提升了开发效率,也减少了潜在的兼容性问题。

http://www.yayakq.cn/news/675358/

相关文章:

  • 免费图纸网站工作室名字创意好听
  • 网站备案怎么那么麻烦西峡网站开发
  • 网站服务器有哪几种万网网站建设流程
  • wordpress 做仿站陕西网站建设哪家专业
  • 网站建设服务费计什么科目seo行业岗位有哪些
  • 网站建设类公司可以拿哪些项目资金ui网站推荐
  • 珠海网站建设专业设计网站营销建设公司
  • 怎么做网站板块网站开发的相关技术
  • 做网络推广要做网站吗教育咨询
  • 网站建设捌金手指花总三那种软件
  • 设计案例分享网站python 做网站缺点
  • 企业做产品网站费用大概是多少河南建设网证书查询平台
  • 高校网站群建设研究南山做网站多少钱
  • 厦门市翔安建设局网站传销公司做网站运营
  • 新余代网站建设公司wordpress显示注册ip
  • 网站 建设 欢迎你厦门网站建设合同
  • 安装php网站西安短视频运营公司
  • 设计一套企业网站多少钱网站建设公司福州
  • 七星网络网站一般网址的正确格式
  • 网站开发 所有权有域名没有服务器怎么做网站
  • 网软志成个人商城网站备案的网站 ,能拿来做仿站吗
  • 做食品网站的素材公司网站邮箱怎么看接收服务器类型
  • 中国万网怎么自己做网站诸暨建设局网站
  • 新乡网站设计公司佛山建站模板
  • 东莞专业拍摄做网站照片网站建设新报价图片欣赏
  • 农业推广新网seo关键词优化教程
  • 骗子会利用钓鱼网站做啥遵义住建局查询网站
  • 网站制作动网页版传奇开服
  • 江门网站建设系统电商网站开发设计文档
  • 如何百度搜索到自己的网站线上卖货平台有哪些