我已经安装了 Python 并在 apache 中进行了配置。我创建了一个 Python Web 文件并在浏览器中打开它,但出现错误。但是在命令行中工作的相同代码。我希望问题出在我的 apache 配置上。
这是错误信息。
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>