attributeError:模块' memcache'没有属性' client'

发布于 2025-01-28 17:52:18 字数 1603 浏览 2 评论 0原文

最近,我在Python项目中实现了Lock.py,用于使用Memcached锁定线程。但是,我概括了一个错误解决的错误。它说memcache不会构成客户端。我不是直接使用客户端,我相信它只是在导入的模块中被调用。我已经安装了dogpile.cache == 1.1.5和使用PIP的Python-Memcached == 1.59。有人可以帮我吗?

这是完整的错误消息:

Exception in thread Thread-1 (mock_process_repo):
Traceback (most recent call last):
  File "/usr/lib64/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/home/jdonic/code/prograde/prograde/lock.py", line 164, in mock_process_repo
    with RepoSyncLock("repository-name"):
  File "/home/jdonic/code/prograde/prograde/lock.py", line 122, in __enter__
    while not lock_cache_region.backend.client.add(
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/cache/backends/memcached.py", line 181, in client
    return self._clients.memcached
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/util/langhelpers.py", line 78, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/cache/backends/memcached.py", line 169, in _clients
    return ClientPool()
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/cache/backends/memcached.py", line 167, in __init__
    self.memcached = backend._create_client()
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/cache/backends/memcached.py", line 313, in _create_client
    return memcache.Client(self.url)
AttributeError: module 'memcache' has no attribute 'Client'

Recently I implemented lock.py in my python project for locking threads, using memcached. However I encoutered an error which I have trouble solving. It says that memcache does not containt attribute Client. I am not using Client directly, I believe it's just being called inside the imported modules. I have installed both dogpile.cache==1.1.5 and python-memcached==1.59 using pip. Could someone please help me?

Here is the full error message:

Exception in thread Thread-1 (mock_process_repo):
Traceback (most recent call last):
  File "/usr/lib64/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/home/jdonic/code/prograde/prograde/lock.py", line 164, in mock_process_repo
    with RepoSyncLock("repository-name"):
  File "/home/jdonic/code/prograde/prograde/lock.py", line 122, in __enter__
    while not lock_cache_region.backend.client.add(
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/cache/backends/memcached.py", line 181, in client
    return self._clients.memcached
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/util/langhelpers.py", line 78, in __get__
    obj.__dict__[self.__name__] = result = self.fget(obj)
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/cache/backends/memcached.py", line 169, in _clients
    return ClientPool()
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/cache/backends/memcached.py", line 167, in __init__
    self.memcached = backend._create_client()
  File "/home/jdonic/.local/lib/python3.10/site-packages/dogpile/cache/backends/memcached.py", line 313, in _create_client
    return memcache.Client(self.url)
AttributeError: module 'memcache' has no attribute 'Client'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小草泠泠 2025-02-04 17:52:18

您可能已经安装了 memcache 安装的python3-memcached,这是一个坏主意。检查您的PIP安装,看看您安装了多少个Memcache客户端:

python3 -m pip freeze | grep memcache

如果您看到多个诸如memcache或python3-memcached之类的东西,那么您需要非常关心,因为它们使用相同的名称空间,所以很可能他们在互相前进:

memcache==0.10.1
python3-memcached==1.51

显然您是您的。正在期望客户端在memcache模块中定义的,因此只需查看一个确实定义的并删除另一个。如果我的内存服务,则python3-memcached == 1.51应该是您想要的。

You probably have both python3-memcached and memcache installed, which is a bad idea. Check your pip installations and see how many memcache clients you have installed:

python3 -m pip freeze | grep memcache

If you see multiple things like memcache or python3-memcached, you need to be very care as they are using the same namespace so very likely they are poluting each other:

memcache==0.10.1
python3-memcached==1.51

Apparently you are expecting Client defined in the memcache module so just take a look at which one does define this and remove the other. If my memory serves, python3-memcached==1.51 should be what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文