python 3.x - Getting Flask to use Python3 (Apache/mod_wsgi) -


i've got basic "hello world" flask app running.

i'm on ubuntu 14.04, using apache 2.4. i've installed mod_wsgi.

i've created ~/web/piflask/venv/ hold virtualenv-created python2 flask installed.

however, wish have flaskapp import python3.x module have written.

what need make happen?

i tried creating ~/web/piflask/venv3/ , modifying ~/web/piflask/piflask.wsgi:

import os, sys  project_dir = '/home/pi/web/piflask'  activate_this = os.path.join(project_dir, 'venv3/bin', 'activate_this.py') execfile(activate_this, dict(__file__=activate_this)) sys.path.insert(0, project_dir)  piflask import app application  application.debug = true 

but don't think sufficient. .wsgi in fact python file executed mod_wsgi, i'm sure use py2.x interpreter execution.

so if i'm understanding correctly, mod_wsgi fires system python in order execute .wsgi, in turn fire ~/web/piflask/venv/ interpreter process request.

i think persuade mod_wsgi use either system python3 or own venv3/... setting wsgipythonpath /home/pi/web/piflask/venv3/lib/python3.4/site-packages in /etc/apache2/mods-available/wsgi.conf

but found instruction somewhere saying have compile mod_wsgi py3, , bottom falls out problem.

correct, mod_wsgi needs compiled specific python version never executes 'python' executable. instead python library linked mod_wsgi.

the end result cannot mix python 3 code within application running using python 2 interpreter.

you have consider making code runnable under both python 2 , 3 , choose of want use , use version of mod_wsgi compiled version choose use.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -