2011-06-23 18 views
2

Apache、mod_wsgi、およびdjangoを設定しようとしています。私は私のApacheのエラーログにこの持つ内部サーバーエラーを取得しています:osという名前のモジュールが見つかりません - Django、mod_wsgi、Apache 2.2

[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Target WSGI script '/django/internal/django-development.wsgi' cannot be loaded as Python module. 
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Exception occurred processing WSGI script '/django/internal/django-development.wsgi'. 
[Wed Jun 22 21:31:55 2011] [error] Traceback (most recent call last): 
[Wed Jun 22 21:31:55 2011] [error] File "/django/internal/django-development.wsgi", line 3, in <module> 
[Wed Jun 22 21:31:55 2011] [error]  import sys, os 
[Wed Jun 22 21:31:55 2011] [error] ImportError: No module named os 
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Target WSGI script '/django/internal/django-development.wsgi' cannot be loaded as Python module. 
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Exception occurred processing WSGI script '/django/internal/django-development.wsgi'. 
[Wed Jun 22 21:31:55 2011] [error] Traceback (most recent call last): 
[Wed Jun 22 21:31:55 2011] [error] File "/django/internal/django-development.wsgi", line 3, in <module> 
[Wed Jun 22 21:31:55 2011] [error]  import sys, os 
[Wed Jun 22 21:31:55 2011] [error] ImportError: No module named os 

ジャンゴ - development.wsgi

#! /usr/bin/env python 

import sys, os 

path = '/django/internal' 
if path not in sys.path: 
    sys.path.append(path) 

os.environ['DJANGO_SETTINGS_MODULE'] = 'internal.settings' 

import django.core.handlers.wsgi 
application = django.core.handlers.wsgi.WSGIHandler() 

(例えば、構成ファイル、)何があるのなら、私に知らせてください私は、あなたは私がこの問題を診断するのを手助けするために投稿することができます。

編集:

これは私が..私は2.5に私のデフォルトのPythonのバージョンを設定すると思って、パラメータ

$otool -L mod_wsgi.somod_wsgi.so: 
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10) 
    /System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1) 

としてのpython2.5では./configureを実行した考慮すると、奇数でありますそして

LoadModule wsgi_module libexec/apache2/mod_wsgi.so 
WSGIScriptAlias//django/internal/django-development.wsgi 

編集:

ああ、悪い設定ファイルがインポートされているようです。私は今私に次の出力を与えるようになった。進捗状況:

[Wed Jun 22 23:04:28 2011] [error] Exception ImportError: 'No module named atexit' in 'garbage collection' ignored 
Fatal Python error: unexpected exception during garbage collection 
[Wed Jun 22 23:04:28 2011] [error] Exception ImportError: 'No module named atexit' in 'garbage collection' ignored 
Fatal Python error: unexpected exception during garbage collection 
[Wed Jun 22 23:04:29 2011] [notice] caught SIGTERM, shutting down 
[Wed Jun 22 23:04:29 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache] 
[Wed Jun 22 23:04:29 2011] [warn] mod_wsgi: Compiled for Python/2.5.4. 
[Wed Jun 22 23:04:29 2011] [warn] mod_wsgi: Runtime using Python/2.6.1. 
[Wed Jun 22 23:04:29 2011] [notice] Digest: generating secret for digest authentication ... 
[Wed Jun 22 23:04:29 2011] [notice] Digest: done 
[Wed Jun 22 23:04:29 2011] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.3 Python/2.6.1 configured -- resuming normal operations 
[Wed Jun 22 23:06:04 2011] [error] [client ::1] client denied by server configuration: /django/internal/django-development.wsgi 

編集

だから、私はまだmod_wsgiを実行するのpython 2.5の代わりに2.6を作成する方法を理解したいのですが - これは、今の私に私の大きな問題を引き起こしているものです。それを超えて、それはちょうどApacheの設定を調整する必要があります。

+0

どのようなバージョンのpythonですか?通常のPythonインタプリタからosをインポートできますか? –

+0

バージョン2.5 - はい、できます。 –

+0

'django-development.wsgi'と同じディレクトリにあるファイルのリストを含めることができますか? –

答えて

1

mod_wsgi何らかの理由でPy2.5ライブラリが表示されません。 WSGIPythonPathの値を確認し、/usr/lib/python2.5のようなものを指すようにしてください。

+0

httpd.confに 'WSGIPythonPath/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5'を入れてApacheを再起動しましたが、これと同じ結果(以前はotoolコマンドと同じ出力) 。 –

+0

:WSGIPythonPathはPythonバイナリへのパスではなく、python modulesディレクトリへの検索パスです。 ':'で区切られたリストの最初のディレクトリは、その中にos.pyがあるディレクトリでなければなりません。詳細については、[ここ](http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonPath)を参照してください。 – Thomas

+0

私は、/usr/lib/python2.5をインクルードするように修正しました(そして、それが正しいことを確認しました)、何らかの理由で2.6で動作する必要があると感じました。 –

関連する問題