I'm running into some trouble with deploying Django on the passenger_wsgi module with virtualenv. The Python code in the passenger_wsgi.py file, which should fix my problem is:
import os, sys
INTERP = '/home/login/.virtualenvs/env_name/bin/python'
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)
The first three lines I understand, but I only have a very vague idea about the fourth one and that's the one that happens to be giving me an error:
/home/login/.virtualenvs/env_name/bin/python: can't find '__main__.py' in ''
So what is os.execl doing here exactly? And what does that error message mean?
maybe you should do it like this:
os.execl(INTERP, *sys.argv) # don't pass again the interpreter path.
i think this doc is wrong : http://wiki.dreamhost.com/Passenger_WSGI
about exec:
The exec functions of Unix-like operating systems are a collection of functions that causes the running process to be completely replaced by the program passed as an argument to the function.
os.execl(path, arg0, arg1, ...)
os.execle(path, arg0, arg1, ..., env)
os.execlp(file, arg0, arg1, ...)
os.execlpe(file, arg0, arg1, ..., env)
os.execv(path, args)
os.execve(path, args, env)
os.execvp(file, args)
os.execvpe(file, args, env)
from : http://docs.python.org/library/os.html
The “l” and “v” variants of the exec*() functions differ in how command-line arguments are passed. The “l” variants are perhaps the easiest to work with if the number of parameters is fixed when the code is written; the individual parameters simply become additional parameters to the execl*() functions. The “v” variants are good when the number of parameters is variable, with the arguments being passed in a list or tuple as the args parameter. In either case, the arguments to the child process should start with the name of the command being run, but this is not enforced.
Edit:
i just did what you were doing in a python shell and i get the same error:
>>> import os
>>> import sys
>>> os.execl('/home/login/projects/virtual/bin/python', '/home/login/projects/virtual/bin/python', *sys.argv)
/home/login/projects/virtual/bin/python: can't find '__main__.py' in ''