我已經安裝了Python並在apache中進行了配置。我創建了一個Python網頁文件,並在瀏覽器中打開這個文件,我得到一個錯誤。但是相同的代碼在命令行中工作。我希望問題來自我的apache配置。python網頁上的錯誤
這是錯誤消息。
MOD_PYTHON ERROR
ProcessId: 6368
Interpreter: 'localhost'
ServerName: 'localhost'
DocumentRoot: '/var/www'
URI: '/python_test/hello_world.py'
Location: None
Directory: '/var/www/'
Filename: '/var/www/python_test/hello_world.py'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'mod_python.py'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1202, in _process_target
module = import_module(module_name, path=path)
File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 304, in import_module
return __import__(module_name, {}, {}, ['*'])
ImportError: No module named py
我的Python代碼是:
print "Hello world!"
My httpd.conf file is :
ServerName localhost
<Directory /var/www/>
Options Indexes FollowSymlinks MultiViews
AllowOverride AuthConfig
order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.py
PythonDebug On
</Directory>
爲什麼啊,爲什麼你還在使用[死多頭的mod_python](http://blog.dscpl.com.au/2010/06/modpython-project-is-now-officially.html)? – Matthias 2013-04-30 15:11:36