Ask Your Question

How can I install ROS Melodic with Python3?

asked 2018-06-22 06:02:48 -0600

pepijndevos gravatar image

I need to use ROS with a library that does not support Python 2, which is over a decade old at this point. I'm finding mixed information about Python 3 support in ROS Melodic.

I'm installing from source using the instructions on the wiki. I used Python 3 to install the initial packages

sudo pip3 install -U rosdep rosinstall_generator wstool rosinstall

After setting up my locale correctly, I got up to the point where wstool has initialised the standalone workspace. But after that I run rosdep to install all the dependencies, and I see a lot of Python 2 packages scrolling by.

rosdep install --os=debian:stretch --from-paths src --ignore-src --rosdistro melodic --skip-keys=sbcl -y

Is there a way ROS Melodic can run on Python 3?

It might be worth mentioning that I could not care less about what the whole system runs on, as long as I can have a single Python 3 node to receive some messages and use this particular Python library. So if I can install rospy on Python 3 that should be enough I think?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-06-22 21:34:48 -0600

kartikmohta gravatar image

The rosdep install step would install python 2 versions of the package since that's how the dependencies are defined. Instead of hunting down the list of dependencies and installing python 3 version of each, it might be easier to just start building and install the missing python 3 package if there is an error. You will need to set the env variable ROS_PYTHON_VERSION to 3 when building to force python 3 otherwise by default it picks python 2.

Also if you just want basic functionality, you probably want to use the ROS-Comm build as described on the Installation page.

edit flag offensive delete link more


The installation worked after installing empy, but it seems messages are not properly generated. On python 3 there is no module named geometry_msgs, and in Python 2 the module geometry_msgs has no msg submodule.

pepijndevos gravatar image pepijndevos  ( 2018-06-23 05:51:36 -0600 )edit

The ROS-Comm meta-package does not contain the geometry_msgs package. You can add the extra packages you want to the rosinstall_generator line when generating your workspace, for example use rosinstall_generator ros_comm geometry_msgs --rosdistro melodic --deps --tar for adding geometry_msgs

kartikmohta gravatar image kartikmohta  ( 2018-06-23 15:39:18 -0600 )edit

answered 2019-07-29 17:21:23 -0600

npscars gravatar image

Maybe just create a seperate catkin workspace with python3 as shown in the following article: link text

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools



Asked: 2018-06-22 06:02:48 -0600

Seen: 22,446 times

Last updated: Jun 22 '18