在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编译通过。
关于以上版本冲突问题,若大家有更好的解决发法,感谢提供,毕竟,每次切换还是觉得麻烦和不太聪明~