ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

rosrun python executable

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

clauniel gravatar image

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

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
1

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

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/fix-python-scripts.sh -v 2 /path/to/src/dir
edit flag offensive delete link more
2

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

kokirits gravatar image

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

gedit ~/.bashrc

or

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

Comments

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 -0600 )edit

Glad I could help!

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

Question Tools

2 followers

Stats

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

Seen: 3,326 times

Last updated: Feb 20 '15