ROS catkin_make与evo python版本冲突问题

在catkin_make编译时出现问题:

ImportError: "from catkin_pkg.topological_order import topological_order" failed: No module named 'catkin_pkg'
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.

提示与PYTHONPATH相关,搜索了其他解决方案,需要添加Python2.7相关的环境变量,说明catkin依赖2.7版本的Python。

方法:输入sudo gedit ~/.bashrc,打开.bashrc文件,在文件末尾加上

export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages

之后记得要source ~/.bashrc,写入一下!

但出现下述问题:

Traceback (most recent call last):
  File "/opt/ros/melodic/bin/catkin_make", line 5, in <module>
    import argparse
  File "/usr/lib/python3.6/argparse.py", line 89, in <module>
    import re as _re
  File "/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
    if not enabled():
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
    import re
  File "/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

Original exception was:
Traceback (most recent call last):
  File "/opt/ros/melodic/bin/catkin_make", line 5, in <module>
    import argparse
  File "/usr/lib/python3.6/argparse.py", line 89, in <module>
    import re as _re
  File "/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

还是提示python版本问题。

安装evo评测工具时,evo依赖于python3.6以上版本,故当时通过update-alternative工具切换至python3.6,所以为了解决catkin_make依赖的python版本问题,故再次转换:

$ sudo update-alternatives --config python 
There are 2 choices for the alternative python (providing /usr/bin/python).
 
  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.6   2         auto mode
  1            /usr/bin/python2.7   1         manual mode
  2            /usr/bin/python3.6   2         manual mode
 
Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode

之后,catkin_make编译通过。

关于以上版本冲突问题,若大家有更好的解决发法,感谢提供,毕竟,每次切换还是觉得麻烦和不太聪明~

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值