LoginSignup
5
5

More than 3 years have passed since last update.

ROS noeticでImportError: No module named rospkgを解決する

Posted at

ImportError: No module named rospkg

いつもどおり
rosrun rqt_topic rqt_topic
したら何故かこのエラーが出たので、同じ目に合った人のためにメモを遺す

原因

Ubuntu 20.04.1だとpythonコマンドはpython2系をまだ指しているので、何もしないでrosrunするとこっちが動いてしまう。しかしROS noeticはPython3で動くように作り直されているのでPython2では動かない。

解決法

update-alternativesでデフォルトを置き換えてやればいい。一応2系に戻せるようにそっちも登録しておく。
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2

私の手元の環境に合わせて決め打ちしたが、マイナーバージョン一個ぐらいはそのうち変わるかもしれないのでそこは適宜合わせてほしい。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5