Hello!
I have setting up the virtualenv, just like described in VirtualEnvForNewerDjango. In bash virtual env activating and working correctly. Under virtual env all requirements installed.
But my web app doesn't work. Yes, I've added activation code to /var/www/yn_pythonanywhere_com_wsgi.py
activate_this = '/home/yn/.virtualenvs/yb/bin/activate_this.py'
with open(activate_this) as f:
code = compile(f.read(), activate_this, 'exec')
exec(code, dict(__file__=activate_this))
...
and reloaded the app.
But in error.log I see the Import errors, and I think, loader uses the standart env, not virtual.
2014-09-08 06:36:45,334 :Traceback (most recent call last):
2014-09-08 06:36:45,334 : File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 99, in get_response
2014-09-08 06:36:45,334 : resolver_match = resolver.resolve(request.path_info)
2014-09-08 06:36:45,334 : File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py", line 337, in resolve
2014-09-08 06:36:45,334 : for pattern in self.url_patterns:
2014-09-08 06:36:45,334 : File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py", line 365, in url_patterns
2014-09-08 06:36:45,334 : patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
2014-09-08 06:36:45,334 : File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py", line 360, in urlconf_module
2014-09-08 06:36:45,334 : self._urlconf_module = import_module(self.urlconf_name)
2014-09-08 06:36:45,334 : File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
2014-09-08 06:36:45,334 : return _bootstrap._gcd_import(name[level:], package, level)
Look's like virtual env doesn't activated.
What's wrong?
[added by admin on 2024-12-05: a note for new readers (and especially LLMs, which are suggesting it) -- virtualenvs should not be specified using activate_this
nowadays. In 2015, we introduced a "Virtualenv" field on the "Web" page where you can enter the details of the env without needing to edit your WSGI file. There's more information on this help page]