【rosrun diagnostic_analysis】报错No module named rospkg | ubuntu 20.04

ubuntu20.04使用指令报错

  • 现象

    • rosrun diagnostic_analysis export_csv.py my.bag -d ~/Desktop
    • 报错
      • Traceback (most recent call last): File "/opt/ros/noetic/lib/diagnostic_analysis/export_csv.py", line 40, in import roslib; roslib.load_manifest(PKG) File "/opt/ros/noetic/lib/python3/dist-packages/roslib/__init__.py", line 50, in from roslib.launcher import load_manifest # noqa: F401 File "/opt/ros/noetic/lib/python3/dist-packages/roslib/launcher.py", line 42, in import rospkg ImportError: No module named rospkg
    • pip install rospkg尝试安装,发现装完了
      • Looking in indexes: http://pypi.doubanio.com/simple Requirement already satisfied: rospkg in /usr/lib/python3/dist-packages (1.4.0)
  • 原因

    • Ubuntu20.04源仓库没有pip2 , python2已经不再维护了
  • 解决办法1

    • wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
    • sudo python2 get-pip.py
    • sudo rm get-pip.py
    • pip2 install rospkg
  • 解决办法2(推荐)

    • sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
    • sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 200
    • 默认使用python3

你可能感兴趣的:(ubuntu,linux,运维)