【发布时间】:2015-01-24 00:27:42
【问题描述】:
我正在尝试将 Django 与 Apache 一起使用,但是当我尝试启动 WSGI 应用程序时,出现以下错误:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
我的 httpd.conf 文件中包含此内容:
WSGIPythonHome /home/ec2-user/anaconda
WSGIScriptAlias / /home/ec2-user/test/wsgi.py
WSGIPythonPath /home/ec2-user/test
<Directory /home/ec2-user/test>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
这是我的 wsgi.py 文件的内容:
import sys
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
print >> sys.stderr, 'sys.prefix = %s' % repr(sys.prefix)
print >> sys.stderr, 'sys.path = %s' % repr(sys.path)
return [output]
【问题讨论】: