Question

Hi I am trying to port my working Django v1.3 application that uses Pylucene from DJANGO Dev server to Apache with mod_wsgi where it gives an error on the same Windows XP machine.

Error Message from Django debug:

ViewDoesNotExist at /administration/feeds/

Could not import plunk4.feeds.views. Error was: DLL load failed: The specified module could not be found.

Request Method: GET Request URL: localhost/administration/feeds/ Django Version: 1.3 Exception Type: ViewDoesNotExist Exception Value:

Could not import plunk4.feeds.views. Error was: DLL load failed: The specified module could not be found.

Exception Location: c:\Python27\lib\site-packages\django\core\urlresolvers.py in _get_callback, line 167 Python Executable: C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe Python Version: 2.7.1 Python Path:

['c:\Python27\lib\site-packages\south-0.7.3-py2.7.egg', 'c:\Python27\lib\site-packages\django_admin_tools-0.4.0-py2.7.egg', 'c:\Python27\lib\site-packages\jcc-2.8-py2.7-win32.egg', 'c:\Python27\lib\site-packages\lucene-3.1.0-py2.7-win32.egg', 'c:\Python27\lib\site-packages\oauth2-1.5.170-py2.7.egg', 'c:\Python27\lib\site-packages\httplib2-0.7.2-py2.7.egg', 'c:\Python27\lib\site-packages\django_social_auth-0.6.0-py2.7.egg', 'c:\Python27\lib\site-packages\python_openid-2.2.5-py2.7.egg', 'c:\Python27\lib\site-packages\python_dateutil-1.5-py2.7.egg', 'c:\Python27\lib\site-packages\distribute-0.6.24-py2.7.egg', 'c:\Python27\lib\site-packages\django_chronograph-0.2.0.dev-py2.7.egg', 'c:\Python27\lib\site-packages\pyofc2-0.1.5dev-py2.7.egg', 'c:\Python27\lib\site-packages\anyjson-0.3.1-py2.7.egg', 'c:\Python27\lib\site-packages\django_pagination-1.0.7-py2.7.egg', 'c:\Python27\lib\site-packages\gdata-2.0.17-py2.7.egg', 'c:\Python27\lib\site-packages\flickrapi-1.4.2-py2.7.egg', 'c:\Python27\lib\site-packages\threadpool-1.2.7-py2.7.egg', 'c:\Python27\Lib', 'c:\test\git_repo\src', 'c:\test\git_repo\src\plunk4', 'c:\test\git_repo\src\plunk4\feeds', 'C:\Python27\Lib\site-packages\lucene-3.1.0-py2.7-win32.egg\lucene', 'C:\Python27\Lib\site-packages\lucene-3.1.0-py2.7-win32.egg\lucene\lib', 'C:\Program Files\Java\jdk1.6.0_30\jre\bin', 'C:\Program Files\Java\jdk1.6.0_30\jre\bin\client', 'C:\Program Files\Apache Software Foundation\Apache2.2', 'C:\WINDOWS\system32\python27.zip', 'c:\Python27\DLLs', 'c:\Python27\lib\plat-win', 'c:\Python27\lib\lib-tk', 'C:\Program Files\Apache Software Foundation\Apache2.2\bin', 'c:\Python27', 'c:\Python27\lib\site-packages']

Server time: Fri, 10 Aug 2012 13:14:36 -0700

Here is the apache error.log

[Fri Aug 10 13:03:03 2012] [warn] mod_wsgi: Compiled for Python/2.7. [Fri Aug 10 13:03:03 2012] [warn] mod_wsgi: Runtime using Python/2.7.1. [Fri Aug 10 13:03:03 2012] [notice] Apache/2.2.22 (Win32) mod_wsgi/3.3 Python/2.7.1 configured -- resuming normal operations [Fri Aug 10 13:03:03 2012] [notice] Server built: Jan 28 2012 11:16:39 [Fri Aug 10 13:03:03 2012] [notice] Parent: Created child process 6780 [Fri Aug 10 13:03:03 2012] [warn] mod_wsgi: Compiled for Python/2.7. [Fri Aug 10 13:03:03 2012] [warn] mod_wsgi: Runtime using Python/2.7.1. [Fri Aug 10 13:03:03 2012] [notice] Child 6780: Child process is running [Fri Aug 10 13:03:04 2012] [notice] Child 6780: Acquired the start mutex. [Fri Aug 10 13:03:04 2012] [notice] Child 6780: Starting 64 worker threads. [Fri Aug 10 13:03:04 2012] [notice] Child 6780: Starting thread to listen on port 80. [Fri Aug 10 13:03:45 2012] [error] [client 127.0.0.1] mod_wsgi (pid=6780): Target WSGI script 'C:/temp/wsgi_test.py' cannot be loaded as Python module. [Fri Aug 10 13:03:45 2012] [error] [client 127.0.0.1] mod_wsgi (pid=6780): Exception occurred processing WSGI script 'C:/temp/wsgi_test.py'. [Fri Aug 10 13:03:45 2012] [error] [client 127.0.0.1] Traceback (most recent call last): [Fri Aug 10 13:03:45 2012] [error] [client 127.0.0.1] File "C:/temp/wsgi_test.py", line 8, in [Fri Aug 10 13:03:45 2012] [error] [client 127.0.0.1]
import jcc [Fri Aug 10 13:03:45 2012] [error] [client 127.0.0.1]
File "c:\Python27\lib\site-packages\jcc-2.8-py2.7-win32.egg\jcc\__init__.py", line 34, in [Fri Aug 10 13:03:45 2012] [error] [client 127.0.0.1] from _jcc import initVM [Fri Aug 10 13:03:45 2012] [error] [client 127.0.0.1] ImportError: DLL load failed: The specified module could not be found.

Lucene appears to work from Python Shell:

C:\Documents and Settings\Carlos>python
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jcc
>>> import lucene
>>> lucene.initVM()
<jcc.JCCEnv object at 0x00AC67C0>
>>> lucene.VERSION
'3.1.0'

Here is the output of python -m jcc.__main__

  JCC - C++/Python Java Native Interface Code Generator

  Usage: python -m jcc.__main__ [options] [actions]

  Input options:
    --jar JARFILE           - make JCC wrap all public classes found in
                              JARFILE, add it to the module's CLASSPATH and
                              include it in the distribution
....

To demonstrate mod_WSGI is installed correctly: I created a c:\temp\wsgi_test.py file below:

import sys

sys.path.append('C:/Python27/Lib/site-packages')
sys.path.append('C:/Python27/Lib/site-packages/lucene-3.1.0-py2.7-win32.egg/lucene')
sys.path.append('C:/Python27/Lib/site-packages/lucene-3.1.0-py2.7-win32.egg/lucene/lib')
sys.path.append('C:/Python27/Lib/site-packages/JCC-2.8-py2.7-win32.egg/jcc.dll')

def application(environ, start_response):
    status = '200 OK'

    output = ''
    output += 'sys.version = %s\n' % repr(sys.version)
    output += 'sys.prefix = %s\n' % repr(sys.prefix)
    output += 'sys.path = %s' % repr(sys.path)
    output += 'wsgi.multithread = %s' % repr(environ['wsgi.multithread'])
    output += 'mod_wsgi.process_group = %s' % repr(environ['mod_wsgi.process_group']) 

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

It returns:

sys.version = '2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)]' sys.prefix = 'c:\Python27' sys.path = ['c:\Python27\lib\site-packages\south-0.7.3-py2.7.egg', 'c:\Python27\lib\site-packages\django_admin_tools-0.4.0-py2.7.egg', 'c:\Python27\lib\site-packages\jcc-2.8-py2.7-win32.egg', 'c:\Python27\lib\site-packages\lucene-3.1.0-py2.7-win32.egg', 'c:\Python27\lib\site-packages\oauth2-1.5.170-py2.7.egg', 'c:\Python27\lib\site-packages\httplib2-0.7.2-py2.7.egg', 'c:\Python27\lib\site-packages\django_social_auth-0.6.0-py2.7.egg', 'c:\Python27\lib\site-packages\python_openid-2.2.5-py2.7.egg', 'c:\Python27\lib\site-packages\python_dateutil-1.5-py2.7.egg', 'c:\Python27\lib\site-packages\distribute-0.6.24-py2.7.egg', 'c:\Python27\lib\site-packages\django_chronograph-0.2.0.dev-py2.7.egg', 'c:\Python27\lib\site-packages\pyofc2-0.1.5dev-py2.7.egg', 'c:\Python27\lib\site-packages\anyjson-0.3.1-py2.7.egg', 'c:\Python27\lib\site-packages\django_pagination-1.0.7-py2.7.egg', 'c:\Python27\lib\site-packages\gdata-2.0.17-py2.7.egg', 'c:\Python27\lib\site-packages\flickrapi-1.4.2-py2.7.egg', 'c:\Python27\lib\site-packages\threadpool-1.2.7-py2.7.egg', 'c:\Python27\Lib', 'c:\test\git_repo\src', 'c:\test\git_repo\src\plunk4', 'c:\test\git_repo\src\plunk4\feeds', 'C:\Python27\Lib\site-packages\lucene-3.1.0-py2.7-win32.egg\lucene', 'C:\Python27\Lib\site-packages\lucene-3.1.0-py2.7-win32.egg\lucene\lib', 'C:\Program Files\Java\jdk1.6.0_30\jre\bin', 'C:\Program Files\Java\jdk1.6.0_30\jre\bin\client', 'C:\Program Files\Apache Software Foundation\Apache2.2', 'C:\WINDOWS\system32\python27.zip', 'c:\Python27\DLLs', 'c:\Python27\lib\plat-win', 'c:\Python27\lib\lib-tk', 'C:\Program Files\Apache Software Foundation\Apache2.2\bin', 'c:\Python27', 'c:\Python27\lib\site-packages', 'C:/Python27/Lib/site-packages', 'C:/Python27/Lib/site-packages/lucene-3.1.0-py2.7-win32.egg/lucene', 'C:/Python27/Lib/site-packages/lucene-3.1.0-py2.7-win32.egg/lucene/lib', 'C:/Python27/Lib/site-packages/JCC-2.8-py2.7-win32.egg/jcc.dll', 'C:/Python27/Lib/site-packages', 'C:/Python27/Lib/site-packages/lucene-3.1.0-py2.7-win32.egg/lucene', 'C:/Python27/Lib/site-packages/lucene-3.1.0-py2.7-win32.egg/lucene/lib', 'C:/Python27/Lib/site-packages/JCC-2.8-py2.7-win32.egg/jcc.dll']wsgi.multithread = Truemod_wsgi.process_group = ''

I have tried the following references to solve the problem: http://code.google.com/a/apache-extras.org/p/pylucene-extra/wiki/PyLucene

Could not import/No module named Django Error with Apache

lists.osafoundation.org/pipermail/pylucene-dev/2007-November/002070.html

grokbase.com/t/lucene/pylucene-dev/125t3g2ph6/jcc-dll-loading-error

Était-ce utile?

La solution

Solution was to utilize Apache Solr instead. This allows me to make REST service calls from Python into Lucene index without the hassles of trying to get Python to call into Java/Lucene.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top