Using Shebang in ROS2

asked 2022-09-25 21:04:31 -0500

arash.k7@gmail.com gravatar image

Hi everyone! I used to be a ROS1 user, but recently I switched to ROS2 foxy. I couldn't use Shebang to change the python environment for running my node (Same as what I used to do in ROS1).

Here is the sample shebang code:

#!/home/user/dev_ws/src/test2/dtw/bin/python3
import cv2
def main():
    print('Hi from test2.')

After running this, still it will be run by default ros python env.

FYI, I have created the package by Colcon.

Anyone know how I could address this issue?

edit retag flag offensive close merge delete

Comments

I believe your objective is to run ROS 2 inside virtualenv. If yes, please see the following link: #q371083

ravijoshi gravatar image ravijoshi  ( 2022-10-03 02:37:35 -0500 )edit

Thanks. I was trying to run different nodes with different virtual environment. The solution I found was using launch file with 'launch-prefix' argument.

arash.k7@gmail.com gravatar image arash.k7@gmail.com  ( 2023-03-14 02:53:37 -0500 )edit