skip to Main Content

I have a strange issue when i try to add a task from the django_celery_beat package on my production server. (Everything runs fine on my local workspace).

I get a No module named pymemcache error but i’ve installed it already on my venv.

On my production server i have a memcached server running and the configuration is the following:

'default': {
            'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
            'LOCATION': '10.100.23.95:11211',
        },

How can i fix this issue ?

Thank you very much for your time

I’ve tried installing the packages again but i don’t understand what i’m doing wrong.

ERROR LOG:

Environment:


Request Method: GET
Request URL: 

Django Version: 4.1.6
Python Version: 3.11.2
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django_countries',
 'phonenumber_field',
 'crispy_forms',
 'django_filters',
 'django_select2',
 'mathfilters',
 'django_quill',
 'corsheaders',
 'captcha',
 'user_visit',
 'django_social_share',
 'django_celery_beat',
 'core.apps.CoreConfig',
 'shopcore.apps.ShopcoreConfig',
 'shopuser.apps.ShopuserConfig',
 'customer.apps.CustomerConfig',
 'product.apps.ProductConfig',
 'catalog.apps.CatalogConfig',
 'discount.apps.DiscountConfig',
 'order.apps.OrderConfig',
 'wishlist.apps.WishlistConfig',
 'basket.apps.BasketConfig',
 'authentification.apps.AuthentificationConfig',
 'front.apps.FrontConfig',
 'vinx.apps.VinxConfig',
 'saferpay.apps.SaferpayConfig',
 'promotion.apps.PromotionConfig',
 'information.apps.InformationConfig',
 'job.apps.JobConfig',
 'newsletter.apps.NewsletterConfig',
 'blog.apps.BlogConfig',
 'dashboard.apps.DashboardConfig',
 'stats.apps.StatsConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'user_visit.middleware.UserVisitMiddleware']



Traceback (most recent call last):
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/contrib/admin/options.py", line 686, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/utils/decorators.py", line 133, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/contrib/admin/sites.py", line 242, in inner
    return view(request, *args, **kwargs)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/contrib/admin/options.py", line 1890, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/utils/decorators.py", line 133, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/contrib/admin/options.py", line 1750, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/contrib/admin/options.py", line 1818, in _changeform_view
    form = ModelForm(initial=initial)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/forms/models.py", line 371, in __init__
    super().__init__(
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/forms/forms.py", line 107, in __init__
    self.fields = copy.deepcopy(self.base_fields)
  File "/opt/jelastic-python311/lib/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/opt/jelastic-python311/lib/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/opt/jelastic-python311/lib/python3.11/copy.py", line 153, in deepcopy
    y = copier(memo)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/forms/fields.py", line 865, in __deepcopy__
    result = super().__deepcopy__(memo)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/forms/fields.py", line 253, in __deepcopy__
    result.widget = copy.deepcopy(self.widget, memo)
  File "/opt/jelastic-python311/lib/python3.11/copy.py", line 153, in deepcopy
    y = copier(memo)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/forms/widgets.py", line 611, in __deepcopy__
    obj.choices = copy.copy(self.choices)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django_celery_beat/admin.py", line 33, in choices
    self._choices = self.tasks_as_choices()
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django_celery_beat/admin.py", line 25, in tasks_as_choices
    _ = self._modules
  File "/opt/jelastic-python311/lib/python3.11/site-packages/kombu/utils/objects.py", line 30, in __get__
    return super().__get__(instance, owner)
  File "/opt/jelastic-python311/lib/python3.11/functools.py", line 1001, in __get__
    val = self.func(instance)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django_celery_beat/admin.py", line 44, in _modules
    self.celery_app.loader.import_default_modules()
  File "/opt/jelastic-python311/lib/python3.11/site-packages/celery/loaders/base.py", line 105, in import_default_modules
    raise response
  File "/opt/jelastic-python311/lib/python3.11/site-packages/celery/utils/dispatch/signal.py", line 276, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/celery/fixups/django.py", line 82, in on_import_modules
    self.worker_fixup.validate_models()
  File "/opt/jelastic-python311/lib/python3.11/site-packages/celery/fixups/django.py", line 121, in validate_models
    run_checks()
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/core/checks/registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/core/checks/caches.py", line 65, in check_file_based_cache_is_absolute
    cache = caches[alias]
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/utils/connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/core/cache/__init__.py", line 52, in create_connection
    return backend_cls(location, params)
  File "/opt/jelastic-python311/lib/python3.11/site-packages/django/core/cache/backends/memcached.py", line 177, in __init__
    import pymemcache.serde

Exception Type: ModuleNotFoundError at /admin/django_celery_beat/periodictask/add/
Exception Value: No module named 'pymemcache'

2

Answers


  1. Chosen as BEST ANSWER

    So i've found the error.

    If you have a jelastic cloud production server verify what venv the server is using.

    Mine was using a different one (the default jelastic one instead of the one that i've created).

    A quick fix is to run the pip install pymemcache outside your venv.


  2. Try this:

    pip install pymemcache
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search