django_celery_beat - 没有名为 'pymemcache' 的模块



我有一个奇怪的问题,当我试图从django_celery_beat添加一个任务包放在我的生产服务器上。(我的本地工作空间一切正常)。

我得到一个No module named pymemcache错误,但我已经在我的venv上安装了它。

在我的生产服务器上,我有一个memcached服务器在运行,配置如下:

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

如何解决这个问题?

非常感谢您的宝贵时间

我试着重新安装软件包,但是我不明白我做错了什么。

错误日志:

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'

试试这个:

pip install pymemcache

我找到错误了。

如果您有一个jelastic云生产服务器,请验证服务器正在使用的venv。

我使用的是一个不同的(默认的jelastic而不是我创建的)。

一个快速的解决办法是在venv之外运行pip install pymemcache

相关内容

  • 没有找到相关文章

最新更新