Whoops. I should have said to add it after any
sys.path/site.addsitedir stuff you do to set up Python module search
path.

If when you restart Apache and try to access application, if the
loading of the WSGI script file fails on that import, then it means
that you have a sys.path or permissions issue.

So, just before the import line, if it still fails, add:

  import sys
  print >> sys.stderr, "PYTHONPATH", sys.path

Then get what is printed from Apache error log file and double check
whether parent directory where 'sphene' is installed is listed in
sys.path.

If it isn't, the parent directory where 'sphene' is installed needs to
be added, or you need to fix up how it is being added.

Find out where 'sphene' is installed by running command line Python and doing:

  import sphene
  print sphene.__file__

The parent directory then is:

  import os
  print os.path.dirname(os.path.dirname(sphene.__file__))

If the directory is listed in sys.path, then it is going to be a
permissions issue.

That is, the user that Apache is running your code as doesn't have
permission to access some directory down to where sphene is installed,
or perhaps even the code of sphene itself.

Graham

On 28 December 2010 13:36, Young <[email protected]> wrote:
> Hi Graham,
>
> Thanks for the help. However the problem still occurs even though I
> added the line in the script.
>
> Young
>
> On Dec 26, 5:44 pm, Graham Dumpleton <[email protected]>
> wrote:
>> At the start of the WSGI script file add:
>>
>>   import sphene.community
>>
>> Does that work and then cause latter problem to go away or does it fail.
>>
>> Graham
>>
>> On 25 December 2010 00:23, Young <[email protected]> wrote:
>>
>>
>>
>>
>>
>>
>>
>> > Hi,
>>
>> > I've been configuring mod-wsgi for days but with no luck. My site runs
>> > well on Django dev server but doesn't work on Apache/mod_wsgi. I read
>> > Graham's nice blog post and it was very helpful to understand how
>> > Django dev server internally works. However it couldn't help to solve
>> > my problem as mine is somewhat complicated.
>>
>> > My site consists of 3 parts: my app, SCT app(wiki/forum,
>> >http://sct.sphene.net/wiki/show/Start/) and jpype module. Though my
>> > code solely runs well on Apache/mod_wsgi but it doesn't with other
>> > modules.
>>
>> > As my site runs well on Django dev server and both errors below are
>> > something like "class/module not found", I guess the error is related
>> > with path problems. However when I printed sys.path, it contained both
>> > '/dfs/mysite' and '/dfs'.
>>
>> > Any comments will be appreciated. Thanks in advance and Merry
>> > Christmas:)
>>
>> > -Young
>>
>> > My machine is:
>> > ###############################################################
>> > - Ubuntu server 10.10 64bit
>> > - Using DFS
>> > - Python 2.6.6
>> > - Django 1.2.3
>> > - mod_wsgi 3.3
>>
>> > Simplified directory structure is:
>> > #################################################
>> > /dfs/mysite/myapp : directory for my app
>> > /dfs/mysite/apache : directory for mod_wsgi script
>> > /dfs/mysite/sphene : director for SCT app
>> > /dfs/mysite/build/classes/com/mysite/myjava/Abc.Class : directory for
>> > JAVA class running on jpype
>>
>> > /etc/apache2/httpd.conf is:
>> > #####################################################
>> > Alias /site_media/ /dfs/mysite/site_media/
>> > <Directory /dfs/mysite/site_media>
>> >    Order deny,allow
>> >    Allow from all
>> > </Directory>
>>
>> > LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
>> > WSGIScriptAlias / /dfs/mysite/apache/django.wsgi
>> > <Directory /dfs/mysite/apache>
>> >    Order deny,allow
>> >    Allow from all
>> > </Directory>
>>
>> > /dfs/mysite/apache/django.wsgi is:
>> > ###############################################
>> > import sys
>> > path1 = '/dfs'
>> > if path1 not in sys.path:
>> >    sys.path.append(path1)
>> > path2 = '/dfs/mysite'
>> > if path2 not in sys.path:
>> >    sys.path.append(path2)
>>
>> > import settings
>> > import django.core.management
>> > django.core.management.setup_environ(settings)
>> > utility = django.core.management.ManagementUtility()
>> > command = utility.fetch_command('runserver')
>> > command.validate()
>>
>> > import django.conf
>> > import django.utils
>> > django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE)
>>
>> > import django.core.handlers.wsgi
>> > application = django.core.handlers.wsgi.WSGIHandler()
>>
>> > Jpype error is:
>> > ################################################################
>> > java.lang.ExceptionPyRaisable at /service/abc/
>> > java.lang.Exception: Class com.mysite.myjava.Abc not found
>>
>> > The Apache error.log is:
>> > #########################################################
>> > [Fri Dec 24 04:25:59 2010] [notice] Apache/2.2.16 (Ubuntu) mod_wsgi/
>> > 3.3 Python/2.6.6 configured -- resuming normal operations
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121] mod_wsgi
>> > (pid=6180): Target WSGI script '/dfs/mysite/apache/django.wsgi' cannot
>> > be loaded as Python module.
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121] mod_wsgi
>> > (pid=6180): Exception occurred processing WSGI script '/dfs/mysite/
>> > apache/django.wsgi'.
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121] Traceback
>> > (most recent call last):
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/dfs/
>> > mysite/apache/django.wsgi", line 18, in <module>
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > command.validate()
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/core/management/base.py",
>> > line 249, in validate
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > num_errors = get_validation_errors(s, app)
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/core/management/
>> > validation.py", line 28, in get_validation_errors
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]     for
>> > (app_name, error) in get_app_errors().items():
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/db/models/loading.py", line
>> > 146, in get_app_errors
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > self._populate()
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/db/models/loading.py", line
>> > 61, in _populate
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > self.load_app(app_name, True)
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/db/models/loading.py", line
>> > 76, in load_app
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > app_module = import_module(app_name)
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35,
>> > in import_module
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > __import__(name)
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121] ImportError:
>> > No module named sphene.community
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121] mod_wsgi
>> > (pid=6181): Target WSGI script '/dfs/mysite/apache/django.wsgi' cannot
>> > be loaded as Python module.
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121] mod_wsgi
>> > (pid=6181): Exception occurred processing WSGI script '/dfs/mysite/
>> > apache/django.wsgi'.
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121] Traceback
>> > (most recent call last):
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/dfs/
>> > mysite/apache/django.wsgi", line 18, in <module>
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > command.validate()
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/core/management/base.py",
>> > line 249, in validate
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > num_errors = get_validation_errors(s, app)
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/core/management/
>> > validation.py", line 28, in get_validation_errors
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]     for
>> > (app_name, error) in get_app_errors().items():
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/db/models/loading.py", line
>> > 146, in get_app_errors
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > self._populate()
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/db/models/loading.py", line
>> > 61, in _populate
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > self.load_app(app_name, True)
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/db/models/loading.py", line
>> > 76, in load_app
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > app_module = import_module(app_name)
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]   File "/usr/
>> > local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35,
>> > in import_module
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121]
>> > __import__(name)
>> > [Fri Dec 24 12:26:10 2010] [error] [client 76.169.74.121] ImportError:
>> > No module named sphene.community
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "modwsgi" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to 
>> > [email protected].
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/modwsgi?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "modwsgi" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/modwsgi?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to