ROS编译工作空间报错,与conda环境冲突

最开始安装ROS的时候很顺利就创建、编译工作空间成功了,后来重装了系统,一阵子之后再装ROS的时候开始报错,提示没有安装某某包等(我的报错如下),经排查是环境问题

(base) frankchen@Ambush:~/code/ROS/catkin_ws$ catkin_make
Base path: /home/frankchen/code/ROS/catkin_ws
Source space: /home/frankchen/code/ROS/catkin_ws/src
Build space: /home/frankchen/code/ROS/catkin_ws/build
Devel space: /home/frankchen/code/ROS/catkin_ws/devel
Install space: /home/frankchen/code/ROS/catkin_ws/install
Creating symlink "/home/frankchen/code/ROS/catkin_ws/src/CMakeLists.txt" pointing to "/opt/ros/noetic/share/catkin/cmake/toplevel.cmake"
####
#### Running command: "cmake /home/frankchen/code/ROS/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/frankchen/code/ROS/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/frankchen/code/ROS/catkin_ws/install -G Unix Makefiles" in "/home/frankchen/code/ROS/catkin_ws/build"
####
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.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/frankchen/code/ROS/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /opt/ros/noetic
-- This workspace overlays: /opt/ros/noetic
-- Found PythonInterp: /home/frankchen/anaconda3/bin/python3 (found suitable version "3.8.5", minimum required is "3") 
-- Using PYTHON_EXECUTABLE: /home/frankchen/anaconda3/bin/python3
-- Using Debian Python package layout
-- Found PY_em: /home/frankchen/anaconda3/lib/python3.8/site-packages/em  
-- Using empy: /home/frankchen/anaconda3/lib/python3.8/site-packages/em
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/frankchen/code/ROS/catkin_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: /home/frankchen/anaconda3/bin/python3 (found version "3.8.5") 
-- Found Threads: TRUE  
-- Using Python nosetests: /usr/bin/nosetests3
ImportError: "from catkin_pkg.package import parse_package" failed: No module named 'catkin_pkg'
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.
CMake Error at /opt/ros/noetic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/home/frankchen/anaconda3/bin/python3
  "/opt/ros/noetic/share/catkin/cmake/parse_package_xml.py"
  "/opt/ros/noetic/share/catkin/cmake/../package.xml"
  "/home/frankchen/code/ROS/catkin_ws/build/catkin/catkin_generated/version/package.cmake")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/catkin_package_xml.cmake:74 (safe_execute_process)
  /opt/ros/noetic/share/catkin/cmake/all.cmake:168 (_catkin_package_xml)
  /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:58 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/frankchen/code/ROS/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/frankchen/code/ROS/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

可以看到在编译过程中使用了conda的python环境以及conda环境中的各种包,就导致会缺少一些与ROS编译过程中所需的包。所以我们需要使用系统环境,值得注意的是此处我是直接打开终端的,并没有激活某个我所创建的conda环境,实则不然,请注意
请添加图片描述
当使用过conda,并且将之添加到.bashrc中后,每次打开终端都已经进入conda名为"(base)"的环境了,如上图最左侧所示,所以我们需要退出这个环境。一些博客给出的解决方法是到.bashrc文件中将有关conda路径的代码注释掉,但之后要用到conda的时候还要取消注释,很繁琐,直接在终端中用命令

$ conda deactivate

退出环境就可以了,如图请添加图片描述
然后重新创建编译工作空间就可以了。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值