How to create a python script that works with python3 and 2
In the install space, python scripts have their shebang changed to the version specified with PYTHON_EXECUTABLE
. In the devel workspace this also happens for globally installed scripts. But when I run a normal script with rosrun, it will take the version specified in the shebang. __How can I create a script that works in both python versions in the devel space?__
I could change the shebang to python3
but then it's not backwards compatible. I would like to have this handled automatically.
Is this a good solution?
#!/usr/bin/env python$ROS_PYTHON_VERSION
/usr/bin/env: ‘python$ROS_PYTHON_VERSION’: No such file or directory
EDITI found that REP-151 will describe the path for switching from Python 2 to Python 3 in ROS 1. It's still WIP, but I found some answers there. https://github.com/ros-infrastructure...