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

ImportError: dynamic module does not define module export function (PyInit__tf2)

asked 2021-01-19 00:04:56 -0500

siddharthcb gravatar image

updated 2021-01-19 00:06:16 -0500

hi, i am trying to run a package built from source on ros melodic. when i run the command i end up with this error:

from tf import TransformListener
  File "/opt/ros/melodic/lib/python2.7/dist-packages/tf/__init__.py", line 30, in <module>
    from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
  File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>
    from tf2_py import *
  File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>
    from ._tf2 import *

from this i understood that it is conflicting with the python path but this solution did not work for me and i get the same error. is there any other way to setup catkin_ws with python3?

edit retag flag offensive close merge delete

Comments

No solution, rather a comment: Using python3 in ROS (pre-noetic) is hard! You'd have to compile everything from source to make this work properly and stumble upon hundreds of problem over and over again. A quick search for this will turn up many, many questions on that, that, in the end all (should) say:

If you need to use python3, use ROS noetic!

(personal opinion, but I'm 100% positive, that this will make your life a lot easier...)

mgruhler gravatar image mgruhler  ( 2021-01-19 02:43:27 -0500 )edit

and stumble upon hundreds of problem over and over again

well, hundreds, that's a bit much perhaps, but I do agree with the advice about using Noetic if you have Python 3 requirements.

gvdhoorn gravatar image gvdhoorn  ( 2021-01-19 04:39:30 -0500 )edit

well, hundreds, that's a bit much perhaps

well, yeah, I like to exaggerate ;-)

mgruhler gravatar image mgruhler  ( 2021-01-19 04:44:05 -0500 )edit

thanks guys! i tried for few days and went on solving errors one by one but ended up crashing everything the entire image and had to flash a new image from scratch :/

i will keep in mind what @mgruhler suggested from next time.

siddharthcb gravatar image siddharthcb  ( 2021-01-28 12:22:04 -0500 )edit

could you close this issue with the appropriate resolution, if you are okay with that? thank you.

mgruhler gravatar image mgruhler  ( 2021-01-29 00:57:30 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-31 05:41:12 -0500

siddharthcb gravatar image

updated 2021-10-12 01:00:59 -0500

As @mgruhler and @gvdhoom pointed out, yes, prenoetic with python3 will land you in so many problems. its better to switch to noetic if you need to work on python3.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-01-19 00:04:56 -0500

Seen: 723 times

Last updated: Oct 12 '21