Setting Django with virtualenvironment on an Apache
<p>I just want to know if you really need to put this code in the <strong>wsgi.py</strong> when you want to deploy in apache with your django virtual environment</p>

<pre><code>activate_env=os.path.expanduser("/path/to/venv")
execfile(activate_env, dict(__file__=activate_env))
</code></pre>

<p>This is not mentioned in the Django docs. However my virtualenv seems not to be used whenever I load my django page on the browser and of course throws a 500 error because my installed packages is not available</p>

<p>Here is my apache conf file:</p>

<pre><code>&lt;VirtualHost *:80&gt;
        ServerName ai-labs.co

        ServerAlias www.ai-labs.co
        ServerAdmin admin@ai-labs.co
        DocumentRoot /var/www/html/ai-labs.co/

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        &lt;Directory /var/www/html/ai-labs.co&gt;
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
        &lt;/Directory&gt;

        Alias /static /var/www/html/ai-labs.co/static
        &lt;Directory /var/www/html/ai-labs.co/static&gt;
                Require all granted
        &lt;/Directory&gt;

        Alias /static /var/www/html/ai-labs.co/media
        &lt;Directory /var/www/html/ai-labs.co/media&gt;
                Require all granted
        &lt;/Directory&gt;

        &lt;Directory /var/www/html/ai-labs.co/ai_labs_website&gt;
                &lt;Files wsgi.py&gt;
                        Require all granted
                &lt;/Files&gt;
        &lt;/Directory&gt;

        WSGIDaemonProcess ai-labs.co python-path=/var/www/html/ai-labs.co:/var/www/html/.virtualenvs_copy/ai-labs-website-pure-django/local/lib/python2.7/site-packages
        WSGIProcessGroup ai-labs.co
        WSGIScriptAlias / /var/www/html/ai-labs.co/ai_labs_website/wsgi.py process-group=ai-labs.co

&lt;/VirtualHost&gt;
</code></pre>

<p>If you configure mod_wsgi correctly, no you don't. Read:</p>

<ul>
<li><a href="http://blog.dscpl.com.au/2014/09/using-python-virtual-environments-with.html" rel="nofollow">http://blog.dscpl.com.au/2014/09/using-python-virtual-environments-with.html</a></li>
</ul>

python django apache