Using python virtual environment for ROS2 on windows

asked 2019-10-15 09:49:08 -0500

some_ros2user gravatar image

It seems that the installation procedure of ROS2 under windows is depending on a python installation in C:\Python37. (As a side node, the recommended "choco install -y python" now installs python 3.8, which is not intended).

I was following the procedure mentioned here https://index.ros.org/doc/ros2/Instal... to install dashing ROS2 on windows. I found out that the ROS2 distribution has a hardcoded dependency on a python 3.7 installation in C:\Python37.

Because we are using python for different projects which may involve or not involve ROS2, I would like to use a python virtual environment for ROS2. However, it seems that this is not supported, because the scripts using the hardcoded shebang

#!c:\python37\python.exe

Even when placing the virtual environment in C:\Python37, the shebang is incorrect, because python would be in

#!c:\python37\Scripts\python.exe

instead. So I am getting errors like "failed to create process" when running ros2. Using "python ros2-script.py" instead works though (assuming an activated virtual environment). Changing the shebang would work in principle, but which scripts should I change?

Is it planned to have an installer in the future who cares about these things?

edit retag flag offensive close merge delete

Comments

Doesn't Windows ignore the shebang? Or are you using some launcher that takes it into account?

gvdhoorn gravatar image gvdhoorn  ( 2019-10-15 10:32:34 -0500 )edit
1

Well, it seems that changing the shebang has an effect. Actually I'm using ros2.exe which fails with original shebang and it runs fine with the changed shebang in ros2-script.py

some_ros2user gravatar image some_ros2user  ( 2019-10-16 03:16:28 -0500 )edit