ImportError: dynamic module does not define init function (init_tf2)
Hello. I am trying to "import tf" in a python 2.7 terminal, but I am getting the following error. Please help me up, as I am unable to proceed further:
svdeepak99@Deepak-Strix:~/catkin_ws$ python
Python 2.7.17 (default, Nov 7 2019, 10:07:09)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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 "/home/svdeepak99/catkin_ws/devel/lib/python3/dist-packages/tf2_ros/__init__.py", line 35, in <module>
exec(__fh.read())
File "<string>", line 38, in <module>
File "/home/svdeepak99/catkin_ws/devel/lib/python3/dist-packages/tf2_py/__init__.py", line 35, in <module>
exec(__fh.read())
File "<string>", line 38, in <module>
ImportError: dynamic module does not define init function (init_tf2)
>>>
I am using ros melodic and Ubuntu 18.04 version. Thanks in advance.
You seem to be mixing Python 2 and Python 3 (note
python2.7/dist-packages/tf
andpython3/dist-packages/tf2_ros
mentioned in the error).You'll have to make sure not to do that.
Thanks for the reply. I tried uninstalling & reinstalling tf & tf2 packages using apt-get multiple number of times, but that doesn't solve my issue. Could you please suggest me how to solve this?