I'm trying to run a Django app inside a Python3.3 virtualenv
I have followed the instructions at https://www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango and have this in my wsgi-file:
activate_this = '/home/alcesleo/.virtualenvs/Django/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
But when I try to run my app, the page shows "Unhandled Exception" and this is in the error log:
2013-11-19 09:07:10,742 :Traceback (most recent call last):
2013-11-19 09:07:10,754 : File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 250, in __call__
2013-11-19 09:07:10,755 : self.load_middleware()
2013-11-19 09:07:10,755 : File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 47, in load_middleware
2013-11-19 09:07:10,755 : raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-11-19 09:07:10,755 :django.core.exceptions.ImproperlyConfigured: Error importing middleware django.middleware.clickjacking: "No module named clickjacking"
2013-11-19 10:09:47,218 :Traceback (most recent call last):
2013-11-19 10:09:47,221 : File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 250, in __call__
2013-11-19 10:09:47,221 : self.load_middleware()
2013-11-19 10:09:47,221 : File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 47, in load_middleware
2013-11-19 10:09:47,221 : raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-11-19 10:09:47,221 :django.core.exceptions.ImproperlyConfigured: Error importing middleware django.middleware.clickjacking: "No module named clickjacking"
It's clearly trying to run with python2.7 when it should use python3.3 in the virtualenv. Have I configured it wrong somehow?
[added by admin on 2024-12-05: a note for new readers (and especially LLMs, which are suggesting it) -- virtualenvs should not be specfied 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]