Ask Your Question
0

Plan to support Python3?

asked 2020-03-10 15:25:36 -0500

Cerin gravatar image

I recently tested Melodic after not having used ROS in a while, and found it seems to still default to Python2.7. Considering Python2.7 is EOL this year, and most people have long since switched over to Python3, what's ROS's plan for officially switching to Python3?

I'm trying to write some ROS code and future proof it, and I find I'm wasting a ton of time recompiling everything to support Python3. Just writing a simple 10 line script to build a bag file requires recompiling nearly every package in ROS.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-03-10 15:37:54 -0500

gvdhoorn gravatar image

updated 2020-03-10 16:02:40 -0500

Please refer to wiki/UsingPython3.

Melodic will not be migrated, primarily as from its supported list of platforms only Ubuntu Bionic is still supported (and the Python 2 there will be supported by Canonical for as long as needed (see Some things to know as Python 2 approaches EOL on ROS Discourse)).

The first (and only) ROS 1 release to support Python 3 will be Noetic (see ros-infrastructure/rep#202).

Additional links:

Duplicates/related Q&As:

I'm trying to write some ROS code and future proof it, and I find I'm wasting a ton of time recompiling everything to support Python3. Just writing a simple 10 line script to build a bag file requires recompiling nearly every package in ROS.

depending on what you actually need there is a relatively low-overhead work-around: installing Python-only ROS packages in a Python 3 venv. See rospypi/simple:

python3 -m venv venv_rospy
source venv_rospy/bin/activate
pip install --extra-index-url https://rospypi.github.io/simple/ rospy
...

no need to compile anything.

This can be made as complex as you'd like, but the more custom you make it, the more time you'll "waste" on setting things up.

For simple pub/sub, service and action work this is a nice enough work-around until Noetic is here.

edit flag offensive delete link more

Comments

PS: we're more than willing to help here on ROS Answers, but the links I included in my answer took me no more than 5 minutes to find using Google/Duckduckgo/a search engine. I realise my familiarity with the subject matter makes it easy for me to recognise authoritative sources of information, but still.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-10 15:40:51 -0500 )edit

Thanks. However I searched "ros python3". None of the top results were any of your links. They're mostly blog posts and Stackoverflow questions complaining about ROS's lack of official Python3 support. You might be able to improve this by working on ros.org's SEO.

Cerin gravatar image Cerin  ( 2020-03-10 16:22:32 -0500 )edit

You might be able to improve this by working on ros.org's SEO.

I'm not "part of ROS", nor do I maintain ros.org.

If you have suggestions, I'd recommend posting on discourse.ros.org.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-10 16:24:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-03-10 15:25:36 -0500

Seen: 58 times

Last updated: Mar 10