开发者

Unable to solve sys path error; module said to be missing

I keep throwing an exception saying a module isn't installed that is. Any help would be much appreciated.

I've looked around and it's been suggested that this error could be solved by extending the sys path to include the app directory. Something I'm pretty sure is taken care of by the sys.path directive in the WSGI file:

import os, sys
sys.path.append('/home/osqa')
sys.path.append('/home/osqa/trunk')
os.environ['DJANGO_SETTINGS_MODULE'] = 'trunk.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

The error output looks like this:

[info] mod_wsgi (pid=15737): Attach interpreter ''.
[info] mod_wsgi (pid=15737): Create interpreter 'trunk|'.
[info] [client 172.31.0.6] mod_wsgi (pid=15737, process='OSQA', application='trunk|'): 
Loading WSGI script '/home/osqa/trunk/apache/django.wsgi'.
[error] [client 172.31.0.6] mod_wsgi (pid=15737): Exception occurred processing WSGI 
script '/home/osqa/trunk/apache/django.wsgi'.
[error] [client 172.31.0.6] Traceback (most recent call last):
[error] [client 172.31.0.6]   File "/usr/lib/python2.6/site-
packages/django/core/handlers/wsgi.py", line 230, in __call__
[error] [client 172.31.0.6]     self.load_middleware()
[error] [client 172.31.0.6]   File "/usr/lib/python2.6/site-
packages/django/core/handlers/base.py", line 42, in load_middleware
[error] [client 172.31.0.6]     raise exceptions.ImproperlyConfigured('Error importing  
middleware %s: "%s"' % (mw_module, e))
[error] [client 172.31.0.6] ImproperlyConfigured: Error importing middleware  
forum.middleware.extended_user: "No module named markdown"

And the Apache Config looks like this:

WSGISocketPrefix run/wsgi
<VirtualHost *:80>
ServerAdmin xxx@xxx.com   
DocumentRoot /home/osqa/trunk
ServerName trunk   
CustomLog logs/osqa.access.log common   
ErrorLog logs/osqa.error.log
WSGIScriptAlias / /home/osqa/trunk/apache/django.wsgi
<Directory> /home/osqa/trunk/apache>
            Order deny,allow
            Allow from all
</Directory>

WSGIDaemonProcess OSQA
WSGIProcessGroup OSQA
Alias /m/ /home/osqa/trunk/forum/skins/     
<Directory /home/osqa/trunk/forum/skins>
            Order deny,allow
            Allow from all
</Directory>
Alias /upfiles/ /home/osqa/trunk/forum/upfiles/
    <Directory /home/osqa/trunk/forum/upfiles>
            Order deny,allow
            Allow from all
    </Directory></VirtualHost>

forum.middleware.extended_user looks like this: from django.contrib.auth.middleware import AuthenticationMiddleware from django.contrib.auth import logoutfrom forum.models.user import AnonymousUser from forum.views.auth import forward_suspended_userimport logging

class ExtendedUser(AuthenticationMiddleware):
def process_request(self, request):
    super(ExtendedUser, self).process_request(request)
    if request.user.is_authenticated():           
     try:
            request.user = request.user.user
            if request.user.is_suspended():       
                user = request.user
                logout(request)
                return forward_suspended_user(request, user)
                return None            
                except Exception, e:               
                    import traceback
                    logging.error("Unable to convert auth_user %s to forum_user: \n%s" % (               开发者_Python百科            request.user.id, traceback.format_exc()
                    ))
    request.user = AnonymousUser()
    return None


Can you post this middleware that's throwing the exception so we can see exactly what it's trying to import?

Sounds like it's importing markdown, and markdown isn't on your path. Normally, this would be installed in your site-packages directory and not so much inside of your project.

try pip install markdown

Update: you said it's definitely installed. Where is markdown installed?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜