Possible to run Python3 in Passenger?

software development


I’m trying to run a web app written in Python 3 with Flask. I managed to set up everything else, the only issue seems to be that (as near as I can tell) Passenger is still calling the system based Python 2.7 and not my installed Python 3.6 which is called by the Virtual Environment and passenger_wsgi.py file.

Here is the error I am receiving (a Web application could not be started error)

Traceback (most recent call last):
File “/dh/passenger/helper-scripts/wsgi-loader.py”, line 320, in
app_module = load_app()
File “/dh/passenger/helper-scripts/wsgi-loader.py”, line 61, in load_app
return imp.load_source(‘passenger_wsgi’, startup_file)
File “passenger_wsgi.py”, line 4, in
os.execl(INTERP, INTERP, *sys.argv)
File “/usr/lib/python2.7/os.py”, line 312, in execl
execv(file, args)
OSError: [Errno 2] No such file or directory

My passenger_wsgi file:

import sys, os
INTERP = os.path.join(os.environ[‘HOME’], ‘mydomain.com’, ‘lenv’, ‘python3’)
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)

from myappname.app import app as application

Is there something I have formatted wrong or something I can do to understand and fix this issue? There shouldn’t be anything /usr/lib/python2.7/os.py and isn’t anywhere in my code, very confused.