The situation changed slightly over the last two years.
You can compile a complete ROS distribution (I tried kinetic) with
catkin build --cmake-args -DPYTHON_VERSION=3.6
assuming you setup a whole core workspace with something like
rosinstall_generator --rosdistro kinetic desktop_full
This works more or less for the core ROS system.
I just filed a few patches to make it even work with MoveIt.
However, Dirk's comment is still true. Sadly even in ROS-melodic (which very few people are using already)
there is no enforced python3 support. By now, this is simply hilarious. But ROS2 will of course make everything better... :/
I had to fix a few lines of code in a number of packages I use myself (including tf), but they are all straight-forward
python2-3 compatibility issues that are well documented.
So everyone, feel free to try it out and file patches if you find more python2-only code somewhere!
We are not that far away from Python3 support anymore.
Originally posted by v4hn with karma: 2950 on 2018-09-08
This answer was NOT ACCEPTED on the original site
Post score: 11
Original comments
Comment by rajat7 on 2018-09-21:
Can you please provide some links or a detailed description of how you built ROS with Python 3?
Comment by tfoote on 2018-09-21:
@rajat7 this is an old post with an accepted answer. This means that most people will not be looking here to answer questions. If you'd like help please ask your own question. The more complete your question the better answer you can expect. https://wiki.ros.org/Support has some suggestions.
Comment by v4hn on 2018-09-21:
This is the best thread for python3 discussions at the moment.
@rajat7: I believe I explained it in quite some detail above and even gave the command lines you need to run. I don't know of any links with more explanations.
Comment by rajat7 on 2018-09-22:
I ran this command, solved each python error as it came and did it all again
But I'm stuck at this error
import rospkg ImportError: No module named rospkg
How to solve this?
Comment by rajat7 on 2018-09-22:
Edit: Solved the above error by setting PYTHONPATH
.
This is the latest one
File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 284
class YAMLObject(metaclass=YAMLObjectMetaclass):
^
SyntaxError: invalid syntax
Comment by rajat7 on 2018-09-23:
This syntax is proper according to Python 3.
It might be the case that it is still using the default python interpreter instead of python3.
Do I need to pass another argument like -DPYTHON_EXECUTABLE=/usr/bin/python3
?
Comment by Bourne on 2021-01-16:
Hi sir @v4hn ,
You said: "I just filed a few patches to make it even work with MoveIt."
Could I know how to make it work in detail?
I read your answers in here https://github.com/ros-planning/moveit/issues/1722, and here https://github.com/ros-planning/moveit/issues/1743 . But there is no such an answer on how to play Moveit in python 3 with Melodic.
Any help would be highly appreciated!!
All the best,