koniu / recoll-webui

web interface for recoll desktop search
275 stars 55 forks source link

AttributeError: 'module' object has no attribute 'connect' #45

Closed patvdv closed 8 years ago

patvdv commented 9 years ago

I have tried to setup the recoll-webui on a CentOS 6.x server with python 2.6.6 installed and each time I am executing a search query through the WSCGI interface I get:

[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20] Traceback (most recent call last):
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]   File "/var/www/html/recoll-webui.home/bottle.py", line 744, in _handle
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]     return route.call(**args)
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]   File "/var/www/html/recoll-webui.home/bottle.py", line 1479, in wrapper
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]     rv = callback(*a, **ka)
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]   File "/var/www/html/recoll-webui.home/bottle.py", line 2850, in wrapper
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]     result = func(*args, **kwargs)
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]   File "/var/www/html/recoll-webui.home/webui.py", line 243, in results
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]     res, nres, timer = recoll_search(query)
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]   File "/var/www/html/recoll-webui.home/webui.py", line 182, in recoll_search
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]     query = recoll_initsearch(q)
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]   File "/var/www/html/recoll-webui.home/webui.py", line 159, in recoll_initsearch
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20]     db = recoll.connect(config['confdir'])
[Thu Oct 01 22:46:14 2015] [error] [client 192.168.0.20] AttributeError: 'module' object has no attribute 'connect'
ghost commented 9 years ago

Hi,

This looks like a version mismatch. What Recoll version are you using ?

patvdv commented 9 years ago

Recoll v1.19.4

ghost commented 9 years ago

This should be ok (I just installed 1.19.4 on a clean ubuntu machine, and it works with the current webui code without a fuss).

Do you have the same problem with a non WSCGI run by the way (using webui-standalone.py) ?

I wonder if you might have several copies of the Python module. Maybe you could search for recoll under /usr/lib and /usr/local/lib:

find /usr/lib/python* /usr/local/lib/python* | grep -i recoll

For reference, a 1.19 recoll module install should look like the following (replacing 2.7 with 2.6 of course, and possibly /usr with /usr/local):

find /usr/lib/python* /usr/local/lib/python* | grep -i recoll
/usr/lib/python2.7/dist-packages/Recoll-1.0.egg-info
/usr/lib/python2.7/dist-packages/recoll
/usr/lib/python2.7/dist-packages/recoll/__init__.py
/usr/lib/python2.7/dist-packages/recoll/rclextract.so
/usr/lib/python2.7/dist-packages/recoll/recoll.so
patvdv commented 9 years ago

Hi Jean-François,

Same problem with the standalone version of the webui. This is the result of the find on my machine (with lib64):

/usr/lib64/python2.6/site-packages/recoll
/usr/lib64/python2.6/site-packages/recoll/recoll.so
/usr/lib64/python2.6/site-packages/recoll/__init__.pyc
/usr/lib64/python2.6/site-packages/recoll/__init__.py
/usr/lib64/python2.6/site-packages/recoll/__init__.pyo
/usr/lib64/python2.6/site-packages/recoll/rclextract.so
/usr/lib64/python2.6/site-packages/Recoll-1.0-py2.6.egg-info
ghost commented 9 years ago

What happens if you start python and type:

from recoll import recoll recoll.connect()

patvdv commented 9 years ago

Looks fine I think:

Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from recoll import recoll
>>> recoll.connect()
<recoll.Db object at 0x7f89abaad0d8>
>>> 
ghost commented 9 years ago

Yes, this looks normal. This is weird. Groping in the dark...

Are several versions of Python installed on the system ?

Does it still work if you paste the whole top of webui.py into python and add the connect() call ? You need to do it while inside the webui directory (so that the bottle etc. modules are found):

import os
import bottle
import time
import sys
import datetime
import glob
import hashlib
import json
import csv
import StringIO
import ConfigParser
import string
import shlex
import urllib

try:
    from recoll import recoll
    from recoll import rclextract
    hasrclextract = True
except:
    import recoll
    hasrclextract = False

try:
    from recoll import rclconfig
except:
    import rclconfig

recoll.connect()
patvdv commented 9 years ago

Actually it does not then, I am getting the error back:

[patrick@elmora recoll-webui.home]$ python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import bottle
>>> import time
>>> import sys
>>> import datetime
>>> import glob
>>> import hashlib
>>> import json
>>> import csv
>>> import StringIO
>>> import ConfigParser
>>> import string
>>> import shlex
>>> import urllib
>>> 
>>> try:
...     from recoll import recoll
...     from recoll import rclextract
...     hasrclextract = True
... except:
...     import recoll
...     hasrclextract = False
... 
>>> try:
...     from recoll import rclconfig
... except:
...     import rclconfig
... 
>>> recoll.connect()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'connect'
>>> 

python 2.6.6 is the only installed version AFAIK

ghost commented 9 years ago

One possible culprit which we left aside is rclextract. Can you please try just:

from recoll import recoll
from recoll import rclextract
recoll.connect()
patvdv commented 9 years ago

This what I get:

[patrick@elmora recoll-webui.home]$ python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from recoll import recoll
>>> from recoll import rclextract
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '_C_API'
>>> recoll.connect()
<recoll.Db object at 0x7f92ae64a0d8>
>>> 
ghost commented 9 years ago

At least an explanation why this is not working. Then for looking for a fix, where does the Recoll Python module comes from ?

patvdv commented 9 years ago

Jean-François,

I have the official package installed:

[patrick@elmora ~]$ rpm -qi recoll-1.19.4-2.el6.x86_64 
Name        : recoll                       Relocations: (not relocatable)
Version     : 1.19.4                            Vendor: (none)
Release     : 2.el6                         Build Date: Mon 15 Jul 2013 11:42:13 AM CEST
Install Date: Mon 15 Jul 2013 11:47:32 AM CEST      Build Host: elmora.home
Group       : Applications/Databases        Source RPM: recoll-1.19.4-2.el6.src.rpm
Size        : 4842354                          License: GPLv2+
Signature   : (none)
URL         : http://www.lesbonscomptes.com/recoll/
Summary     : Desktop full text search tool with Qt GUI
Description :
Recoll is a personal full text search package for Linux, FreeBSD and
other Unix systems. It is based on a very strong back end (Xapian), for
which it provides an easy to use, feature-rich, easy administration
interface.

[patrick@elmora ~]$ rpm -q --filesbypkg recoll-1.19.4-2.el6.x86_64 | grep py
recoll                    /usr/lib64/python2.6/site-packages/Recoll-1.0-py2.6.egg-info
recoll                    /usr/lib64/python2.6/site-packages/recoll
recoll                    /usr/lib64/python2.6/site-packages/recoll/__init__.py
recoll                    /usr/lib64/python2.6/site-packages/recoll/__init__.pyc
recoll                    /usr/lib64/python2.6/site-packages/recoll/__init__.pyo
recoll                    /usr/lib64/python2.6/site-packages/recoll/rclextract.so
recoll                    /usr/lib64/python2.6/site-packages/recoll/recoll.so
recoll                    /usr/share/recoll/filters/hotrecoll.py
recoll                    /usr/share/recoll/filters/hotrecoll.pyc
recoll                    /usr/share/recoll/filters/hotrecoll.pyo
recoll                    /usr/share/recoll/filters/rclexecm.py
recoll                    /usr/share/recoll/filters/rclexecm.pyc
recoll                    /usr/share/recoll/filters/rclexecm.pyo
recoll                    /usr/share/recoll/filters/rcllatinclass.py
recoll                    /usr/share/recoll/filters/rcllatinclass.pyc
recoll                    /usr/share/recoll/filters/rcllatinclass.pyo
recoll                    /usr/share/recoll/filters/rclpython
recoll                    /usr/share/recoll/images/text-x-python.png
ghost commented 9 years ago

Unfortunately I have no centos6 installation around, so I can't be sure, but it seems likely that there is a problem with the recoll-python package.

I tried to build and and install python-recoll with python2.6 (on Debian wheezy), and the webui works just fine (Python 2.6 needs the argparse module to run the webui, but I guess that you already installed this).

So it seems likely that your best bet would be to build recoll from source.

patvdv commented 9 years ago

Hi Jean-François,

I will not go down the route of compiling from source. For the moment I will stick to recoll desktop & CLI. But thank you for extensive help anyway :+1:

koniu commented 8 years ago

CentOS pkg issue? Hopefully rectified upstream. Feel free to reopen if needed.

IrvinPoe commented 7 years ago

Hello,

I got the same error on Recoll version1.23.2, under Arch Linux.

The python lib had been installed for Python3, but the WebUI wants Python2 I think.

Although after compiling the python module for python2, I still had the error :

ImportError: librecoll-1.23.2.so: cannot open shared object file: No such file or directory

Which I "fixed" by linking /usr/lib/recoll/librecoll-1.23.2 to /usr/lib/librecoll-1.23.2

After that, the WebUI worked like a charm.