Ask Your Question

rosrun python executable

asked 2015-01-09 03:26:21 -0500

clauniel gravatar image

updated 2015-01-09 04:16:39 -0500

How do you set which python executable rosrun uses? I am on Arch linux and I assume rosrun defaults to python 3 while trying to interpret python 2.7 source, which of course fails.

EDIT: The issue was in the package scripts. They used "#!/usr/bin/env python" which defaults to python3 on Archlinux. I changed it to "#!/usr/bin/python2".

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-02-20 07:36:58 -0500

bchr gravatar image

On Arch, since /usr/bin/python points to Python 3, some steps need to be taken when using ROS:

  • Force the use of Python 2 by providing Python 2 paths/executables to catkin/CMake (as explained in the wiki),
  • Patch shebang lines of Python scripts to ensure that Python 2 is used. All the ROS packages available in the AUR are fixed automatically thanks to a script available in ros-build-tools:
# Fix Python2/Python3 conflicts
/usr/share/ros-build-tools/ -v 2 /path/to/src/dir
edit flag offensive delete link more

answered 2015-01-09 03:34:09 -0500

kokirits gravatar image

updated 2015-01-09 03:35:03 -0500

gedit ~/.bashrc


gedit ~/[your_workspace]/devel/setup.bash

And check the Python path.

I once had a similar problem where the Anaconda python interpreter messed up with catkin_make and srvs.

edit flag offensive delete link more


Afaik, PYTHONPATH points to libraries, not the executable. Changing it did not make a difference, however you led me on the right track. Thanks!

clauniel gravatar image clauniel  ( 2015-01-09 04:13:59 -0500 )edit

Glad I could help!

kokirits gravatar image kokirits  ( 2015-01-09 04:18:25 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2015-01-09 03:26:21 -0500

Seen: 2,316 times

Last updated: Feb 20 '15