Start an interactive python shell from each of your two web roots (<meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">/home/www/domain2/project/static and </span><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">/home/www/domain1/project/static) and try issuing:</span><div>
<font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><span class="Apple-style-span" style="border-collapse: collapse;"><span class="Apple-style-span" style="font-size: 13px; "><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">from config import django_wsgi</font></span></span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">If one of them fails with an ImportError, but the config/django_wsgi.py file is really there, you could just be missing an __init__.py file inside the config directory which is what tells python to treat that folder as a package directory.<br>
</span></font><br><div class="gmail_quote">On Thu, Jul 22, 2010 at 9:29 AM, James <span dir="ltr">&lt;<a href="mailto:unbit@scottisheyes.com">unbit@scottisheyes.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I&#39;m back with another dynamic virtual hosting/virtualenv question (related to <a href="http://projects.unbit.it/uwsgi/wiki/DynamicVirtualenv" target="_blank">http://projects.unbit.it/uwsgi/wiki/DynamicVirtualenv</a>).  I&#39;ve got uwsgi starting with this:<div>

<br></div><div>uwsgi -s /tmp/uwsgi.sock --vhost --no-site -C -M -p4</div><div><br></div><div>I&#39;ve got two separate domains set up with nginx in two separate nginx config files which get included in the nginx main configuration file:</div>

<div><div><br></div><div>-------------------</div><div><br></div><div>    upstream domain1_upstream {</div><div>        server unix:///tmp/uwsgi.sock;</div><div>    }</div></div><div><br></div><div><div>    server {</div>

<div>        listen       80;</div><div>        server_name  <a href="http://www.domain1.com" target="_blank">www.domain1.com</a>;</div><div><br></div><div>        location / {</div><div>            root /home/www/domain1/project/static;</div>

<div>            uwsgi_pass domain1_upstream;</div><div>            include uwsgi_params;</div><div>            uwsgi_param SCRIPT_NAME /;</div><div>            uwsgi_param UWSGI_SCRIPT config.django_wsgi;</div><div>            uwsgi_param UWSGI_PYHOME /home/www/domain1/;</div>

<div>        }</div><div>    }</div></div><div><br></div><div>-------------------</div><div><br></div><div>and the second file:</div><div><br></div><div>-------------------</div><div><br></div><div><div><div>    upstream domain2_upstream {</div>

<div>        server unix:///tmp/uwsgi.sock;</div><div>    }</div></div><div><br></div><div><div>    server {</div><div>        listen       80;</div><div>        server_name  <a href="http://www.domain1.com" target="_blank">www.domain1.com</a>;</div>

<div><br></div><div>        location / {</div><div>            root /home/www/domain2/project/static;</div><div>            uwsgi_pass domain2_upstream;</div><div>            include uwsgi_params;</div><div>            uwsgi_param SCRIPT_NAME /;</div>

<div>            uwsgi_param UWSGI_SCRIPT config.django_wsgi;</div><div>            uwsgi_param UWSGI_PYHOME /home/www/domain2/;</div><div>        }</div><div>    }</div></div></div><div><br></div><div>-------------------</div>

<div><br></div><div>Both of the above files are trimmed down to keep things brief.  Here is the django_wsgi.py file that the UWSGI_SCRIPT param refers to (it is the same for both domains):</div><div><br></div><div><div>-------------------</div>

<div><br></div><div>import os, sys</div><div>PATH_BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))</div><div><div>PATH_PROJECT = os.path.join(PATH_BASE, &#39;project&#39;)</div></div><div><br></div><div>

activate_this = os.path.join(PATH_BASE, &#39;bin/activate_this.py&#39;)</div><div>execfile(activate_this, dict(__file__=activate_this))</div><div><br></div><div>sys.path.append(PATH_PROJECT)</div><div>sys.path.append(PATH_BASE)</div>

<div><br></div><div>os.environ[&#39;DJANGO_SETTINGS_MODULE&#39;] = &#39;settings&#39;</div><div><br></div><div>import django.core.handlers.wsgi</div><div>application = django.core.handlers.wsgi.WSGIHandler()</div></div><div>

<br></div><div>-------------------</div><div><br></div><div><br></div><div>I keep getting an &quot;ImportError: No module named django_wsgi&quot; for one of the domains, but the other one works fine.  I am missing something, but can&#39;t figure out what.  Can someone shed some light on this for me?</div>

<div><br></div><div>Thank you,</div><div>James</div>
<br>_______________________________________________<br>
uWSGI mailing list<br>
<a href="mailto:uWSGI@lists.unbit.it">uWSGI@lists.unbit.it</a><br>
<a href="http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi" target="_blank">http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Stephen Crosby<br>Web Developer<br><a href="http://lithostech.com">lithostech.com</a><br>
</div>