rapidpro / casepro

Case management dashboard for RapidPro
BSD 3-Clause "New" or "Revised" License
21 stars 31 forks source link

'manage.py migrate' fails with "ImportError: cannot import name get_cache" #15

Closed citizenrich closed 8 years ago

citizenrich commented 8 years ago

Traceback (most recent call last): File "manage.py", line 8, in execute_from_command_line(sys.argv) File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/core/management/init.py", line 353, in execute_from_command_line utility.execute() File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/core/management/init.py", line 327, in execute django.setup() File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/init.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/apps/config.py", line 123, in create import_module(entry) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/Users/richard/Dropbox/Code/casepro/casepro/casepro/orgs_ext/init.py", line 5, in from dash.orgs.models import Org File "/Users/richard/Dropbox/Code/casepro/casepro/env/src/dash-master/dash/orgs/models.py", line 7, in from dash.api import API File "/Users/richard/Dropbox/Code/casepro/casepro/env/src/dash-master/dash/api/init.py", line 12, in from redis_cache import get_redis_connection File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/redis_cache/init.py", line 1, in from django_redis import get_redis_connection File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django_redis/init.py", line 3, in from django.core.cache import get_cache ImportError: cannot import name get_cache

rowanseymour commented 8 years ago

Looks like you have the wrong redis client version. You should create a virtualenv for CasePro and install everything from pip-freeze.txt, i.e.

virtualenv env
. env/bin/activate
pip install -r pip-freeze.txt
citizenrich commented 8 years ago

used a venv actually, but used pip-requires not pip-freeze

rowanseymour commented 8 years ago

Ah ok. That will install the latest latest of all dependencies which is not what CasePro is expecting.

citizenrich commented 8 years ago

Ok, yet more fun. Swear I'm following the dev instructions perfectly, except using pip-freeze not requires:

Traceback (most recent call last): File "manage.py", line 8, in execute_from_command_line(sys.argv) File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/core/management/init.py", line 351, in execute_from_command_line utility.execute() File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/core/management/init.py", line 303, in execute settings.INSTALLED_APPS File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/conf/init.py", line 48, in getattr self._setup(name) File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/conf/init.py", line 44, in _setup self._wrapped = Settings(settings_module) File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/django/conf/init.py", line 92, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/Users/richard/Dropbox/Code/casepro/casepro/casepro/init.py", line 5, in from .celery import app as celery_app File "/Users/richard/Dropbox/Code/casepro/casepro/casepro/celery.py", line 5, in from celery import Celery File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/celery/init.py", line 131, in from celery import five # noqa File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/celery/five.py", line 153, in from kombu.utils.compat import OrderedDict # noqa File "/Users/richard/Dropbox/Code/casepro/casepro/env/lib/python2.7/site-packages/kombu/utils/init.py", line 19, in from uuid import UUID, uuid4 as _uuid4, _uuid_generate_random ImportError: cannot import name _uuid_generate_random

rowanseymour commented 8 years ago

Hmm did you start with a clean virtualenv before installing from pip-freeze.txt?

citizenrich commented 8 years ago

deactivated and rm -rf the env/ dir. Not clean enough?

citizenrich commented 8 years ago

Seems to be working fine on fresh Ubuntu 14.4.3 x64, just may be my Mac.

citizenrich commented 8 years ago

Only hiccup when using a non-local dev server is that runserver has to be opened up, and getting a strange message. Prob a bad config of mine:

[2016-02-07 13:52:32,184: ERROR/MainProcess] Task casepro.cases.tasks.process_new_unsolicited[33cfc2e0-a497-4c40-a56c-7b89d745d7f4] raised unexpected: TembaConnectionError() Traceback (most recent call last): File "/home/admin/casepro/env/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task R = retval = fun(_args, _kwargs) File "/home/admin/casepro/env/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in protected_call return self.run(_args, _kwargs) File "/home/admin/casepro/casepro/cases/tasks.py", line 27, in process_new_unsolicited process_new_org_unsolicited(org) File "/home/admin/casepro/casepro/cases/tasks.py", line 55, in process_new_org_unsolicited after=last_time, before=this_time, pager=pager) File "/home/admin/casepro/env/src/rapidpro-python/temba_client/v1/init.py", line 370, in get_messages return Message.deserialize_list(self._get_multiple('messages', params, pager)) File "/home/admin/casepro/env/src/rapidpro-python/temba_client/clients.py", line 193, in _get_multiple return self._get_page(endpoint, params, pager) File "/home/admin/casepro/env/src/rapidpro-python/temba_client/clients.py", line 209, in _get_page response = self._request('get', url, params=params) File "/home/admin/casepro/env/src/rapidpro-python/temba_client/clients.py", line 106, in _request raise TembaConnectionError() TembaConnectionError: Unable to connect to host

rowanseymour commented 8 years ago

Re the UUID error, seems you've run into this issue where latest CPython breaks kombu https://github.com/celery/kombu/issues/545

I actually fixed this in the refactor branch (just requires updating the kombu version) which I'm hoping to merge later today. If you're just trying to setup a local dev instance, feel free to switch to that branch.

Re the TembaConnectionError. CasePro can't run without a RapidPro instance to connect to. By default it expects to connect to RapidPro on http://localhost:8001/.

citizenrich commented 8 years ago

Thanks

citizenrich commented 8 years ago

other than setting the api to https://app.rapidpro.io/api/v1, is there any other reason for a temba connection error (beyond blocked ports)?

rowanseymour commented 8 years ago

Not that I can think of. If you switch to the refactor branch you should point the API setting to https://app.rapidpro.io without the api/v1 part as it will use both v1 and v2 API versions.

citizenrich commented 8 years ago

cheers! will check it.