ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

ROS Melodic python3

asked 2021-02-19 10:03:21 -0500

pak gravatar image

Hello everyone, as the title suggests I am looking for a way to use python3 rather than python2 as an interpreter. I am aware of the presence of several similar questions however in none of these I am able to find a complete answer. Also in the first tutorial proposed by the site there is a reference to the possibility of using python3 by building from source but it is just a reference linked to the different catkin command to build the workspace. Is there anyone that can share with me a possibile solution or something to read in order to reach it please?

edit retag flag offensive close merge delete

Comments

2

Without links to things you've tried and the errors you ran into, no-one can help you. We only run the risk of suggesting things you've already tried, which is not an efficient way of spending our time.

If you've seen what I believe you've seen, then those "similar questions" and "first tutorial" do actually allow you to build ROS Melodic using Python 3. But it's not a simple copy-paste process, as ROS Melodic simply wasn't written with Python 3 in mind.

In general: please take note of my comment under the answer below.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-20 12:25:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-02-20 09:35:24 -0500

cambel07 gravatar image

updated 2021-02-20 09:35:54 -0500

I struggled a lot to do the same. I was not able to compile everything into python3 because of the many specific dependencies of some ros core packages on python2 but I was able to have a working environment with half of the default ROS packages using python2 and my packages using python3. And I use some workarounds when I need to use TF in python3 which I actually do not use very often.

Here is my repo, it may give you an idea of what I do, specially the Docker file.

edit flag offensive delete link more

Comments

1

You both struggle as it's essentially not supported. ROS Melodic does not support Python 3 natively.

It's possible, but I would not recommend anyone doing this unless you "know what you are doing", by which I mean: you understand CMake, the way ROS normally builds packages, how to configure CMake to use certain (versions of) dependencies, managing different Python environments and versions, the binary linking process, etc, etc.

For future readers: if you want/need to use Python 3, use ROS Noetic. Or perhaps something like catkin_virtualenv.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-20 12:22:04 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-02-19 10:03:21 -0500

Seen: 2,435 times

Last updated: Feb 20 '21