attributeError:模块' memcache'没有属性' client'
最近,我在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能已经安装了 memcache 安装的
python3-memcached
,这是一个坏主意。检查您的PIP安装,看看您安装了多少个Memcache客户端:如果您看到多个诸如memcache或python3-memcached之类的东西,那么您需要非常关心,因为它们使用相同的名称空间,所以很可能他们在互相前进:
显然您是您的。正在期望
客户端
在memcache模块中定义的,因此只需查看一个确实定义的并删除另一个。如果我的内存服务,则python3-memcached == 1.51
应该是您想要的。You probably have both
python3-memcached
andmemcache
installed, which is a bad idea. Check your pip installations and see how many memcache clients you have installed: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:
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.