koniu / recoll-webui

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

Error 500: Internal Server Error #11

Closed wonx closed 10 years ago

wonx commented 10 years ago

Hello,

I must have been doing something wrong, but when I try to test the latest version of recoll-webui, after I open the website and do a search, I always get the same error:

Sorry, the requested URL 'http://xxx.xxx.xxx.xxx:8080/results?query=hello&dir=%3Call%3E&after=&before=&sort=relevancyrating&ascending=0&page=1' caused an error:

Internal Server Error

Exception:

AttributeError("'module' object has no attribute 'connect'",)

Traceback:

Traceback (most recent call last):
  File "/home/user/recoll-webui-master/bottle.py", line 744, in _handle
    return route.call(**args)
  File "/home/user/recoll-webui-master/bottle.py", line 1479, in wrapper
    rv = callback(*a, **ka)
  File "/home/user/recoll-webui-master/bottle.py", line 2850, in wrapper
    result = func(*args, **kwargs)
  File "/home/user/recoll-webui-master/webui.py", line 253, in results
    res, nres, timer = recoll_search(query)
  File "/home/user/recoll-webui-master/webui.py", line 193, in recoll_search
    query = recoll_initsearch(q)
  File "/home/user/recoll-webui-master/webui.py", line 177, in recoll_initsearch
    db = recoll.connect(config['confdir'])
AttributeError: 'module' object has no attribute 'connect'

I am using it together with recoll 1.19.5. Is there something I am doing wrong?

Thanks in advance

ghost commented 10 years ago

Hi,

Please check that your webui.py file has code like the following near the top:

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

This is to confirm that your copy is indeed updated for the 1.19 Recoll Python package.

If this is ok, then the next possibility is that there is a mixup of both versions of the Recoll Python package installed. There should be a "recoll" directory where your local python packages are installed (e.g.: /usr/lib/python2.7/dist-packages, but this could be under /usr/local and/or under site-packages). Check that there is no recoll.so file at the same level as the recoll directory (there should be a recoll.so inside the recoll directory). If there is a recoll.so at the same level as the directory, just delete it.

I sure regret having chosen the same name (recoll) for the package as was previously used for the module, it's causing no end of trouble...

wonx commented 10 years ago

Yes, the copy is updated; the code is exactly as you wrote it.

I only found one copy of recoll.so, inside the "recoll" directory in "/usr/lib/python2.6/dist-packages.

I tried now to completely uninstall recoll and delete the previous database and reinstall it again, with no luck. I still get the same error. The operating system of the computer where it is running is Debian 6. However, I tried your script in my laptop computer (Linux mint 14) and it works, so there must be something wrong with my server. Maybe the python version is too old?

ghost commented 10 years ago

I have no reason to believe that the module does not work with Python 2.6, but I'm not too sure I've ever tested either.

This has to be an issue with the Recoll Python module, no need to reinstall anything else or rebuild the index.

Could you please try the following:

wonx commented 10 years ago
user@box-media:~$ python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from recoll import recoll
>>> recoll.connect()
<recoll.Db object at 0xb73ef080>
>>> 

What else?

ghost commented 10 years ago

At this point we know that things are working normally when you load the recoll module from the command line python, but not from the recoll-webui script.

Does it make any difference if you start Python with "/usr/bin/env python" instead of the above ? This is how the script starts Python.

Where did you start the webui script from ?

I'm just poking in the dark, really, I have no real idea what may be happening here, except that it seems that the script is somehow loading the wrong thing as a recoll module... So this should have something to do with the Python module search path (sys.path), or the current directory when the script is started.

wonx commented 10 years ago

It doesn't make any difference if I start python with "/usr/bin/env python" and run the same commands.

I'm starting the script from my home directory:

user@box-media:~$ cd
user@box-media:~$ cd recoll-webui-master/
user@box-media:~/recoll-webui-master$ ./webui-standalone.py
Bottle server starting up (using WSGIRefServer())...
Listening on http://box-media:3888/
Hit Ctrl-C to quit.

From this terminal, I can see the search queries. I usually enter the URL from another computer in the same network, but now I also tried it from the local server, and I get the same error message.

ghost commented 10 years ago

Ok. I'm out of ideas at this point.

I think I'll try to install debian 6 in a virtual machine and see if I can reproduce the problem.

The standard Debian recoll packages are not up to date. How did you install 1.19.5 (I want to do it like you) ?

wonx commented 10 years ago

Don't worry. I should upgrade my server to a clean version of debian 7, because I've been messing up with my current installation so much that it isn't strange that sometimes things stop working unexpectedly.

I installed the last version of recoll using repositories. Add the following to /etc/apt/sources.list

#Recoll
deb http://ppa.launchpad.net/recoll-backports/recoll-1.15-on/ubuntu lucid main
deb-src http://ppa.launchpad.net/recoll-backports/recoll-1.15-on/ubuntu lucid main

Also, I run my X programs inside a VNC server. And the whole server is virtualised inside a openVZ container.

wonx commented 10 years ago

By the way. I quickly installed a debian 7 server, with recoll 1.19.5 the way I just told you, and then I try to run your script (this time from the /root directory), I get:

root@box-media7:~/recoll-webui-master# ./webui-standalone.py
Traceback (most recent call last):
  File "./webui-standalone.py", line 3, in <module>
    import webui
  File "/root/recoll-webui-master/webui.py", line 13, in <module>
    import recoll
ImportError: No module named recoll
root@box-media7:~/recoll-webui-master# 

Also:

root@box-media7:~# python
Python 2.7.3 (default, Jan  2 2013, 16:53:07) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from recoll import recoll
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named recoll
>>> 
ghost commented 10 years ago

Are you still using the lucid packages ? Because they probably install for python 2.6 and you are now running python 2.7

Here is what I did:

-> Worked

I noticed by the way that recoll-webui needs the topdirs variable to be explicitely defined in ~/.recoll/recoll.conf, which is not necessarily the case for a default recoll install (it defaults to ~). Anyway, topdirs = ~ did it.

I am not sure that it's really wise to use the PPA Ubuntu packages on Debian. I wonder if you might not be better off just compiling recoll from source (which is really not hard). This business of choosing the Ubuntu release by trial and error does not appear too sound to me :)

wonx commented 10 years ago

Under debian wheezy (7.1), and using the oneiric (not quantal) version of the PPA, i've been able to install a recoll version (1.19.3) that worked with your script. Also, I think that python-recoll isn't needed in the last version of recoll. (not sure)

I know, using an Ubuntu ppa in Debian is not wise at all. It just was quick and dirty way of trying recoll in my server. Now that I see that it's possible to make it work, I'll find a more appropiate way of installing it.

Thank you for your patience, you are doing a great job!

ghost commented 10 years ago

using the oneiric (not quantal)

Oops, sorry, I seem to have trouble with my alphabet. And the worse thing is that I did try qantal before going back to oneiric which is the one with which it did work, and then I do it again by writing qantal !

dsheyp commented 9 years ago

Hello.

I have the exact same problem as described by wonx. Everything works as expected with webui-standalone.py but with webui-wsgi.py there is exactly the same error as described by wonx.

my python version is 2.7 i downloaded and installed the packages directly from https://github.com/koniu/recoll-webui i checked everything that you wrote above.

do you have any idea what could be wrong?

many thanks in advance

dsheyp commented 9 years ago

Hello

Ok. I found a solution. As you set a user and group for the WSGIDaemonProcess you have to make sure, this user has access to the index-files and also the config in ~/.recoll/

thanks for this great software