views:

31

answers:

2

hello, i am able to get xapian working as expected with python on my development server but i am having issues with my web server.

i keep running into this error:

import xapian Traceback (most recent call last): File "", line 1, in File "/home/x/lib/python2.6/xapian/init.py", line 28, in _xapian = swig_import_helper() File "/home/x/lib/python2.6/xapian/init.py", line 27, in swig_import_helper return _mod UnboundLocalError: local variable '_mod' referenced before assignment

i installed the latest copy of swig and reinstalled both xapian core and xapian-bindings but the error persists.

any ideas are greatly appreciated.

+1  A: 

I believe the problem here will be in the installation of the xapian-bindings package.

The xapian bindings for Python consist of two parts - a part written in python, and a compiled module. You've clearly installed the python part successfully (ie, /home/x/lib/python2.6/xapian/init.py), but when the python part attempts to load the compiled module, it fails to import it.

Unfortunately, a bug (possibly in swig) is causing another error to be thrown, so you don't see the exception from the failed import. To see the import error, remove line 27 of modern/xapian.py; ie, change it from reading:

try:
    _mod = imp.load_module('_xapian', fp, pathname, description)
finally:
    fp.close()
    return _mod

to reading:

try:
    _mod = imp.load_module('_xapian', fp, pathname, description)
finally:
    fp.close()

You don't say how you've installed xapian-bindings, what platform you're on, or what version of Xapian you're using, so I can't really speculate how you've got into this state. Hopefully, the full exception will be enlightening.

Richard Boulton
ah ha, this helped catch a better exception:
dave
>>> import xapianTraceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/x/lib/python2.6/xapian/__init__.py", line 28, in <module> _xapian = swig_import_helper() File "/home/x/lib/python2.6/xapian/__init__.py", line 24, in swig_import_helper _mod = imp.load_module('_xapian', fp, pathname, description)ImportError: /home/x/lib/python2.6/xapian/_xapian.so: undefined symbol: PyUnicodeUCS4_EncodeUTF8
dave
A: 

oddly this issue went away when i found a different tar.gz file to attempt. thanks for looking.

dave