Ros2 rolling mixes python versions

asked 2022-08-22 04:11:27 -0500

Tilman gravatar image

Hi, I just upgraded Ubuntu from 20.04 to 22.04 and installed ros2 rolling. When building ros messages I get an error that a python module is missing. When I print sys.path in the failing script it shows:

['/opt/ros/rolling/lib/rosidl_generator_py', '/opt/ros/rolling/lib/python3.10/site-packages', '/opt/ros/rolling/local/lib/python3.10/dist-packages', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/someuser/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']

And sys.version shows that python3.6 is used. When I run the same commands in a python console I get 3.10 and all paths are set correctly. Does anyone know how to make ros use the correct python version?

edit retag flag offensive close merge delete

Comments

did you solve this problem? i got same problem

swkim gravatar image swkim  ( 2023-08-01 10:11:00 -0500 )edit
1

I can't remember what I did exactly but I think there might be two solutions. Either remove the old python version from your system or create a virtualenv and make it use a specific version via the -p command argument.

Tilman gravatar image Tilman  ( 2023-08-01 11:36:25 -0500 )edit

Thank you :)

swkim gravatar image swkim  ( 2023-08-01 12:04:06 -0500 )edit