Apache显示“Python版本不匹配”与mod_wsgi

我试图让web.py工作。

我已经编译mod_wsgi来使用python2.6,并正确configuration了我的虚拟主机(至less我确定它是!)。 你好,世界应用程序不断显示为404。我将Apache的日志级别更改为info。 并看到以下内容:

[Wed Sep 28 15:41:12 2011] [info] mod_wsgi (pid=25969): Attach interpreter ''. [Wed Sep 28 15:42:55 2011] [info] mod_wsgi (pid=25969): Create interpreter 'clearpoint.turnleftllc.com|/budgetcalculator'. [Wed Sep 28 15:45:33 2011] [info] mod_wsgi (pid=25969): Destroying interpreters. [Wed Sep 28 15:45:33 2011] [info] mod_wsgi (pid=25969): Destroy interpreter 'clearpoint.turnleftllc.com|/budgetcalculator'. [Wed Sep 28 15:45:33 2011] [info] mod_wsgi (pid=25969): Cleanup interpreter ''. [Wed Sep 28 15:45:33 2011] [info] mod_wsgi (pid=25969): Terminating Python. [Wed Sep 28 15:45:33 2011] [error] Exception KeyError: KeyError(-1216178416,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored [Wed Sep 28 15:45:33 2011] [info] mod_wsgi (pid=25969): Python has shutdown. Fatal Python error: Interpreter not initialized (version mismatch?) 

关于KeyError,我真的不确定这是从哪里来的。 我从命令行(python26 code.py)testing了应用程序,并且执行时没有错误。 事实上它没有任何输出。

以防万一,这里是我的VirtualHostconfiguration,以及应用程序代码:

Python代码(直接从web.py站点获取):

 #!/usr/bin/python26 import web urls = ( '/.*', 'index' ) class index: def GET(self): return "Hello, world!" app = web.application(urls,globals()).wsgifunc() 

虚拟主机:

 <VirtualHost xxx.xxx.xxx.xxx:80> ServerAdmin "[email protected]" ServerName clearpoint.turnleftllc.com ServerAlias clearpoint ErrorLog logs/clearpoint_error_log DocumentRoot /home/turnleftllc/public_html/cpccs WSGIScriptAlias /budgetCalculator /home/turnleftllc/public_html/cpccs/apps/code.py Alias /budgetCalculator/static /home/turnleftllc/public_html/cpccs/apps/static AddType text/html .py <Directory /home/turnleftllc/public_html/cpccs> Order allow,deny Allow from all AllowOverride All </Directory> <Directory /home/turnleftllc/public_html/cpccs/apps> Order allow,deny Allow from all </Directory> </VirtualHost> 

我正在使用CentOS5,默认为python2.4。 我没有卸载并重新编译mod_wsgi for python2.6(正如你可以看到在输出中,它绝对初始化2.6)。

任何帮助将不胜感激!

确保你还没有加载mod_python到相同的Apache。

阅读以下内容并validation您的安装。

http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Installation_In_Use

http://code.google.com/p/modwsgi/wiki/InstallationIssues

KeyError消息是因为你使用的是旧的mod_wsgi版本,而不是最新版本,所以如果你是从源代码构build的,请确保你使用了mod_wsgi 3.3。