title: from _jcc import initVM DLL load failed: The specified module could not be found
body: <p>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. </p>
  
  <p><strong>Error Message from Django debug:</strong></p>
  
  <blockquote>
    <p>ViewDoesNotExist at /administration/feeds/</p>
    
    <p>Could not import plunk4.feeds.views. Error was: DLL load failed: The
    specified module could not be found.</p>
    
    <p>Request Method:   GET Request URL:
      localhost/administration/feeds/ Django Version:     1.3 Exception
    Type:     ViewDoesNotExist Exception Value:   </p>
    
    <p>Could not import plunk4.feeds.views. Error was: DLL load failed: The
    specified module could not be found.</p>
    
    <p>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:  </p>
    
    <p>['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']</p>
    
    <p>Server time:  Fri, 10 Aug 2012 13:14:36 -0700</p>
  </blockquote>
  
  <p><strong>Here is the apache error.log</strong></p>
  
  <blockquote>
    <p>[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]<br>
    import jcc [Fri Aug 10 13:03:45 2012] [error] [client 127.0.0.1]<br>
    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.</p>
  </blockquote>
  
  <p><strong>Lucene appears to work from Python Shell:</strong>  </p>
  
  <pre><code>C:\Documents and Settings\Carlos&gt;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.
  &gt;&gt;&gt; import jcc
  &gt;&gt;&gt; import lucene
  &gt;&gt;&gt; lucene.initVM()
  &lt;jcc.JCCEnv object at 0x00AC67C0&gt;
  &gt;&gt;&gt; lucene.VERSION
  '3.1.0'
  </code></pre>
  
  <p><strong>Here is the output of python -m jcc.__main__</strong></p>
  
  <pre><code>  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
  ....
  </code></pre>
  
  <p>To demonstrate mod_WSGI is installed correctly:
  I created a c:\temp\wsgi_test.py file below:</p>
  
  <pre><code>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]
  </code></pre>
  
  <p>It returns:</p>
  
  <blockquote>
    <p>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 = ''</p>
  </blockquote>
  
  <p><strong>I have tried the following references to solve the problem:</strong>
  <a href="http://code.google.com/a/apache-extras.org/p/pylucene-extra/wiki/PyLucene" rel="nofollow noreferrer">http://code.google.com/a/apache-extras.org/p/pylucene-extra/wiki/PyLucene</a></p>
  
  <p><a href="https://stackoverflow.com/questions/1656159/could-not-import-no-module-named-django-error-with-apache">Could not import/No module named Django Error with Apache</a></p>
  
  <p><a href="http://lists.osafoundation.org/pipermail/pylucene-dev/2007-November/002070.html" rel="nofollow noreferrer">lists.osafoundation.org/pipermail/pylucene-dev/2007-November/002070.html</a></p>
  
  <p><a href="http://grokbase.com/t/lucene/pylucene-dev/125t3g2ph6/jcc-dll-loading-error" rel="nofollow noreferrer">grokbase.com/t/lucene/pylucene-dev/125t3g2ph6/jcc-dll-loading-error</a></p>