<p dir="auto">It would be nice if <a href="http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/" rel="nofollow">http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/</a> and hence <code class="notranslate">flask/docs/deploying/mod_wsgi.rst</code> sported some information on Python 3's venv virtual environment:</p>
<p dir="auto">The information needed to deploy with <code class="notranslate">venv</code>is available here:</p>
<p dir="auto"><a href="https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html" rel="nofollow">https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html</a></p>
<p dir="auto">Basically no <code class="notranslate">activate_this</code>-code is needed in the .wsgi file, just <code class="notranslate">WSGIDaemonProcess myapp python-home=/usr/local/venvs/myapp</code> in your httpd/apache config.</p>
<p dir="auto">I'll draft something to merge if you think it is a good idea, otherwise this will have to serve as reference.</p>
<p dir="auto">It says <a href="http://flask.pocoo.org/docs/0.11/deploying/mod_wsgi/" rel="nofollow">in the documentation</a> (the last section - "Working with Virtual Environments"):</p>
<blockquote>
<p dir="auto">For Python 3 add the following lines to the top of your .wsgi file:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="activate_this = '/path/to/env/bin/activate_this.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))"><pre class="notranslate"><code class="notranslate">activate_this = '/path/to/env/bin/activate_this.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))
</code></pre></div>
</blockquote>
<p dir="auto">However <code class="notranslate">activate_this.py</code> is no longer present in pyvenv (see <a href="http://bugs.python.org/issue21496" rel="nofollow">http://bugs.python.org/issue21496</a>), thus the above code doesn't work. I found a stackoverflow answer where it said that just copying <code class="notranslate">activate_this.py</code> from a 2.7 virtualenv might work, however I didn't go down that route.</p>
<p dir="auto">How I managed to get it working:</p>
<p dir="auto">I added <code class="notranslate">WSGIPythonHome /path/to/env</code> to the top level of my apache config (ie. outside of VirtualEnv). However that might be a little to big of a hammer if people want to run multiple applications in the same Apache instance. In that case setting <code class="notranslate">python-path</code> on <code class="notranslate">WSGIDaemonProcess</code> might work (however I didn't try it out).</p>