0
$\begingroup$

Rosanswers logo

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.


Originally posted by Cerin on ROS Answers with karma: 940 on 2020-03-10

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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:

  • #q318114
  • #q337296

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.


Originally posted by gvdhoorn with karma: 86574 on 2020-03-10

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by gvdhoorn on 2020-03-10:
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.

Comment by Cerin on 2020-03-10:
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.

Comment by gvdhoorn on 2020-03-10:\

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.