Forums

ImportError: No module named 'mptt'

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?

I've add the trace output to wsgi

2014-09-08 07:07:36 <code object <module> at 0x7f78cccf4390, file "/home/yn/.virtualenvs/yb/bin/activate_this.py", line 6>
2014-09-08 07:07:36 ----------
2014-09-08 07:07:36 WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x24e0e60 pid: 26511 (default app)

and I see that activate_this is proceeded. yn is a user name, yb is a virtualenv name.

Why django couldn't see the virtual piped packages?

The usual cause of this sort of error is that you installed the packages into the virtualenv for a different version of Python or that you created the virtualenv for a different version of Python than the one your web app is running.

Ok, I see. I've been already install all requirements with pip3.4 --user, to home folder, and all packages are included correcly. I think, problem is in python versions, as you say.