1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RosInstall: catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3が通らない人へ

Last updated at Posted at 2020-04-01

症状

公式チュートリアルに沿ってROSをインストール後にcatkin_makeするとpython絡みで怒られる。

$ cd catkin_ws
$ catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3
...
-- Found PythonInterp: /usr/bin/python3 (found version "3.6.9") 
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.
...

原因

ROS「/usr/bin/python3見に行ってるけどcatkin_pkgが無いやで」
とのことなので、とりあえず/usr/bin/python3を見に行く。

$ ls /usr/bin/ -l | grep python3
lrwxrwxrwx 1 root root   9  1月 31 05:02 python3 -> python3.6

どうもrosはシステムのpython3系を見に行っているけど、そのpython3.6にcatkin_pkgが入っていないのでエラー吐いてる。

対応

システムが使ってるpython3.6にros用のライブラリを入れるのが嫌なのでpyenvでros用のpythonを作ってあげることにする。

  • pyenvでros用の環境作成・不足したライブラリを導入
$ pyenv install 3.7.6
Installed Python-3.7.6 to /home/xxx/.pyenv/versions/3.7.6

$ pyenv global 3.7.6
$ pip install catkin_pkg
  • python3.7.6でcatkin_make
$ cd ~/catkin_ws
$ catkin_make -DPYTHON_EXECUTABLE=~/.pyenv/versions/3.7.6/bin/python3.7
  • 今後手軽にcmと打つだけでros用のpython環境でbuildできるようにしておく
$ echo "alias cm='cd ~/catkin_ws && catkin_make -DPYTHON_EXECUTABLE=~/.pyenv/versions/3.7.6/bin/python3.7'" >> ~/.bashrc
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?