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/开发者_StackOverflow社区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.
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.
精彩评论