问题描述
我正在使用apache,mod_wsgi,virtual env设置Django我有一个虚拟环境,我想在这里使用: [Missleading name - long story!]
/ home / andy / Dev / python / async-mongo /
我下载了 mod_wsgi 并以root身份使用virtual_env进行编译
我以root身份运行:
我设置了WSGIPythonHome&路径在http.conf
WSGIPythonHome / home / andy / dev / python / async-mongo /
WSGIPythonPath / home /andy/dev/python/async-mongo/lib/python2.6/site-packages
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
我想我按照
当我运行Hello World应用程序时, strong> work
def application(environ,start_response):
status ='200 OK'
output ='Hello World!'
response_headers = [('Content-type','text / plain'),
('Content-Length',str(len(输出))) ]
start_response(status,response_headers)
return [output]
当我尝试导入模块时,失败:
import sys;引发异常(sys.path)
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]
我在apache日志中看到的错误是:
... .....
我猜想某处某处我仍然引用旧的系统级python,但我不明白在哪里。如何解决这个问题?
你在这里提出例外:
import sys;提高异常(sys.path)
I'm setting up Django with apache, mod_wsgi, virtual env
I have a virtual env that I want to use here: [Missleading name - long story!] /home/andy/Dev/python/async-mongo/
I downloaded mod_wsgi and compiled it with virtual_env as root
I ran as root:
I setup WSGIPythonHome & Path in http.conf
WSGIPythonHome /home/andy/dev/python/async-mongo/
WSGIPythonPath /home/andy/dev/python/async-mongo/lib/python2.6/site-packages
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
I think I followed the instructions at http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
When I run the 'Hello World' app it works
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)
return [output]
When I try to import a module it fails:
import sys; raise Exception(sys.path)
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]
The error I see in the apache logs is:
........
I am guessing that somewhere somehow I am still referencing the old system level python but I can not understand where. How can I fix this?
You are raising an exception here:
import sys; raise Exception(sys.path)
这篇关于Django,mod_wsgi和虚拟环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!