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

rqt_graph not finding QT4

asked 2015-06-07 15:42:13 -0600

John Nagle gravatar image

Ubuntu 14.04 LTS / 64 bit. ROS/Gazebo Jade installed per instructions at "http://wiki.ros.org/jade/Installation/Ubuntu"

I'm working through the tutorials, in order. Everything went well until the first use of "rqt_graph" in the turtle tutorial. This produced the error:

rosrun rqt_graph rqt_graph
Traceback (most recent call last):
  File "/opt/ros/jade/lib/rqt_graph/rqt_graph", line 8, in <module>
    sys.exit(main.main(sys.argv, standalone='rqt_graph.ros_graph.RosGraph'))
  File "/opt/ros/jade/lib/python2.7/dist-packages/rqt_gui/main.py", line 59, in main
    return super(Main, self).main(argv, standalone=standalone, plugin_argument_provider=plugin_argument_provider, plugin_manager_settings_prefix=str(hash(os.environ['ROS_PACKAGE_PATH'])))
  File "/opt/ros/jade/lib/python2.7/dist-packages/qt_gui/main.py", line 336, in main
    from python_qt_binding import QT_BINDING
  File "/opt/ros/jade/lib/python2.7/dist-packages/python_qt_binding/__init__.py", line 55, in <module>
    from .binding_helper import loadUi, QT_BINDING, QT_BINDING_MODULES, QT_BINDING_VERSION  # @UnusedImport
  File "/opt/ros/jade/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 265, in <module>
    getattr(sys, 'SELECT_QT_BINDING_ORDER', None),
  File "/opt/ros/jade/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 84, in _select_qt_binding
    QT_BINDING_VERSION = binding_loader(required_modules, optional_modules)
  File "/opt/ros/jade/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 139, in _load_pyqt
    _named_import('PyQt4.%s' % module_name)
  File "/opt/ros/jade/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py", line 106, in _named_import
    module = builtins.__import__(name)
AttributeError: 'module' object has no attribute '__import__'

For Python 2.7, that's a standard error. There is no

builtins.__import__

in Python 2.7.6. That feature is in Python 3, but not 2.7.6. Try this:

>python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import builtins
>>> builtins.__import__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__import__'

Now, in Python 2.7.9, it's different. There, "builtins" isn't defined, so the code at line 36 does import __builtin__ as builtins

after which "builtins.__import__" is defined.

This looks like an incompatibility between "/opt/ros/jade/lib/python2.7/dist-packages/python_qt_binding/binding_helper.py" and Python 2.7.6. Although that file is under the dist-packages directory for ROS Jade's Python library, it's not a standard Python component; it's a ROS component. See "http://wiki.ros.org/python_qt_binding".

Note that on this Ubuntu system, Qt isn't installed in the system Python. That's what you get with the base Ubuntu configuration. So it's possible that this works on systems where Qt is already present and the fancy binding loader isn't needed. I'm not sure. But the "_named_import" function in that module can't work with Python 2.7.6, which is the default with Ubuntu 14.04 LTS, even with all current updates.

edit retag flag offensive close merge delete

Comments

QT4 is installed in the stock Python. "import PyQt4" will work. It's only "binding helper" that seems to be broken. Incidentally, installing Python 2.7.9 as the default Python is not an option; that apparently breaks some Ubuntu 14.04 tools.

John Nagle gravatar image John Nagle  ( 2015-06-07 17:10:06 -0600 )edit

From the Python documentation: "__import__ is an advanced function that is not needed in everyday Python programming, unlike importlib.import_module()." It's an internal function which changes between Python releases. Using it in binding_helper is a bug. Importlib should be used instead.

John Nagle gravatar image John Nagle  ( 2015-06-07 17:17:39 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-08 13:31:17 -0600

John Nagle gravatar image

Reported as an issue/bug: https://github.com/ros-visualization/...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-06-07 15:42:13 -0600

Seen: 577 times

Last updated: Jun 07 '15