TF2 Error: AttributeError: 'module' object has no attribute 'Buffer'
Hello! I encountered an error when I tried to rosrun tf2_tools view_frames.py. I got the error:
[INFO] [1540707214.255858]: Listening to tf data during 5 seconds...
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/tf2_tools/view_frames.py", line 81, in <module>
main()
File "/opt/ros/kinetic/lib/tf2_tools/view_frames.py", line 44, in main
buffer = tf2_ros.Buffer()
AttributeError: 'module' object has no attribute 'Buffer'
Did anyone encounter this problem before?
Edit: In a terminal, if I type which python: output: /usr/bin/python
$ python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tf2_ros
>>> from tf2_ros import Buffer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name Buffer
>>>
Edit2:
~$ dpkg -l | grep tf2
ii ros-ardent-ros-base 0.4.0-1xenial-20180720-153419-0800 amd64 A package which extends 'ros_core' and includes other basic functionalities like tf2 and urdf.
ii ros-ardent-tf2 0.8.0-0xenial-20180208-143331-0800 amd64 tf2 is the second generation of the transform library, which lets the user keep track of multiple coordinate frames over time.
ii ros-ardent-tf2-eigen 0.8.0-0xenial-20180208-144727-0800 amd64 tf2_eigen
ii ros-ardent-tf2-geometry-msgs 0.8.0-0xenial-20180208-144706-0800 amd64 tf2_geometry_msgs
ii ros-ardent-tf2-msgs 0.8.0-0xenial-20180208-143840-0800 amd64 tf2_msgs
ii ros-ardent-tf2-ros 0.8.0-0xenial-20180208-144018-0800 amd64 This package contains the ROS bindings for the tf2 library, for both Python and C++.
ii ros-kinetic-tf2 0.5.18-0xenial-20180824-102527-0800 amd64 tf2 is the second generation of the transform library, which lets the user keep track of multiple coordinate frames over time.
ii ros-kinetic-tf2-bullet 0.5.18-0xenial-20180824-124622-0800 amd64 tf2_bullet
ii ros-kinetic-tf2-eigen 0.5.18-0xenial-20180824-124619-0800 amd64 tf2_eigen
ii ros-kinetic-tf2-geometry-msgs 0.5.18-0xenial-20180824-132241-0800 amd64 tf2_geometry_msgs
ii ros-kinetic-tf2-kdl 0.5.18-0xenial-20180824-132631-0800 amd64 KDL binding for tf2
ii ros-kinetic-tf2-msgs 0.5.18-0xenial-20180824-101445-0800 amd64 tf2_msgs
ii ros-kinetic-tf2-py 0.5.18-0xenial-20180824-123846-0800 amd64 The tf2_py package
ii ros-kinetic-tf2-ros 0.5.18-0xenial-20180824-125648-0800 amd64 This package contains the ROS bindings for the tf2 library, for both Python and C++.
ii ros-kinetic-tf2-sensor-msgs 0.5.18-0xenial-20180824-132057-0800 amd64 Small lib to transform sensor_msgs with tf.
ii ros-kinetic-tf2-tools 0.5.18-0xenial-20180824-132425-0800 amd64 tf2_tools
ii ros-kinetic-turtle-tf2 0.2.2-0xenial-20180824-132015-0800 amd64 turtle_tf2 demonstrates how to write a tf2 broadcaster and listener with the turtlesim.
Edit 3 :
If I run source /opt/ros/kinetic/setup.bash
, I got a different error:
/opt/ros/kinetic$ rosrun tf2_tools view_frames.py
[INFO] [1540844394.031532]: Listening to tf data during 5 seconds...
[INFO] [1540844399.056461]: Generating graph in frames.pdf file...
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/tf2_tools/view_frames.py", line 81, in <module>
main()
File "/opt/ros/kinetic/lib/tf2_tools/view_frames.py", line 52, in main
with open('frames.gv', 'w') as f:
IOError: [Errno 13] Permission denied: 'frames.gv'
no, and this is a rather strange error, as all of this should have been installed for you.
So:
1) I installed ROS by sudo apt-get install ros-kinetic-desktop-full 2) The OS is Ubuntu 16.04 3) I have not install any python interpreter or Anaconda, at least not that I know of. But my python version is 2.7.12
What is the output of
which python
?And what is the output of:
Please copy-paste the output into your original question. Use the
edit
button/link for that.That is rather strange.
What is the output of
dpkg -l | grep tf2
?Let's take a step back: are you still (trying to) use the TF2 package in your workspace, as in #q306956?
Can you please do the following and then test if things work. In a new terminal:
Similar to #q306956: do things work when you don't use your workspace?