[Python-projects] pylint needs X display?

Mads Kiilerich mads at kiilerich.com
Sun Jun 20 19:36:14 CEST 2010


mad wrote, On 06/20/2010 07:11 PM:
> Hi!
>
> I am using pylint and had so far no problems. Now I want to run automatic
> checks. Problem is, when I run pylint from cron or for example from an 'ssh -
> x' session, I get a 'can not open display error. What can I do to check the
> source code without a display?
>
> Thanks in advance,
> mad
>
> $ pylint some_software.py
> ************* Module ccms_software
> [...]
> error while building astng for /usr/lib/python2.6/site-
> packages/gtk-2.0/gtk/__init__.py
> Traceback (most recent call last):
>    File "/usr/lib/python2.6/site-packages/logilab/astng/manager.py", line 126,
> in astng_from_file
>      astng = ASTNGBuilder(self).file_build(filepath, modname)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/builder.py", line 118,
> in file_build
>      node = self.string_build(data, modname, path)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/builder.py", line 128,
> in string_build
>      return self.ast_build(parse(data + '\n'), modname, path)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/builder.py", line 147,
> in ast_build
>      self.rebuilder.walk(node)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/rebuilder.py", line 89,
> in walk
>      self._walk(node)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/rebuilder.py", line
> 109, in _walk
>      self._walk(child, node)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/rebuilder.py", line
> 103, in _walk
>      handle_leave = node.accept(self)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/nodes.py", line 159, in
> accept
>      return func(self)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/rebuilder.py", line
> 188, in visit_from
>      imported = node.root().import_module(node.modname)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/scoped_nodes.py", line
> 297, in import_module
>      module = MANAGER.astng_from_module_name(modname)
>    File "/usr/lib/python2.6/site-packages/logilab/astng/manager.py", line 168,
> in astng_from_module_name
>      module = load_module_from_name(modname)
>    File "/usr/lib/python2.6/site-packages/logilab/common/modutils.py", line 96,
> in load_module_from_name
>      return load_module_from_modpath(dotted_name.split('.'), path, use_sys)
>    File "/usr/lib/python2.6/site-packages/logilab/common/modutils.py", line
> 136, in load_module_from_modpath
>      module = load_module(curname, mp_file, mp_filename, mp_desc)
>    File "/usr/lib/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 79, in
> <module>
>      _init()
>    File "/usr/lib/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 67, in
> _init
>      _gtk.init_check()
> RuntimeError: could not open display
> E: 35: No name 'glade' in module 'gtk'
>    

The core of the problem seems to be that pygtk tries to initialize 
itself when the module is loaded. pygtk has thus intentionally been 
designed to not be loadable without X. (I have just been discussing 
another aspect of this on 
https://bugzilla.redhat.com/show_bug.cgi?id=553757)

pylint could perhaps implement an ugly workaround, but it would probably 
be better to ask pygtk devs what they suggest. If would be nice if they 
could change their implementation, but that is probably not a short term 
solution.

Perhaps you can run your tests in some kind of X virtual frame buffer 
such as Xvfb/Xnest/Xephyr?

/Mads


More information about the Python-Projects mailing list