Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Redis' object has no attribute 'module_list' #3893

Closed
Ahmedniz1 opened this issue May 1, 2023 · 19 comments · Fixed by #4932
Closed

AttributeError: 'Redis' object has no attribute 'module_list' #3893

Ahmedniz1 opened this issue May 1, 2023 · 19 comments · Fixed by #4932

Comments

@Ahmedniz1
Copy link

I'm trying to make a vectorstore using redis and store the embeddings in redis.
When I write the code
rds = Redis.from_documents(docs, embeddings, redis_url="redis://localhost:6379", index_name='test_link')
I get the following error
AttributeError: 'Redis' object has no attribute 'module_list'.
Note: I'm trying to run redis locally on windows subsystem ubuntu.
Please help.

@tylerhutcherson
Copy link
Contributor

tylerhutcherson commented May 3, 2023

Which version of the redis python client and LC are you using? I'm not able to reproduce this with unit tests (just added a from_documents test method.

Wonder if it's possible module names are colliding in your working env too.

@Ahmedniz1
Copy link
Author

I have redis server in windows subsystem (ubuntu) and its Redis server v=6.0.16
on python side, its redis version 3.5.3

@tylerhutcherson
Copy link
Contributor

Can you try with the latest redis client version (>=4.5.2)

@Ahmedniz1
Copy link
Author

sorry for the late reply. I updated the redis version to 4.5.4. When I run the piece of code, it says
ValueError: Redis failed to connect: You must add the RediSearch (>= 2.4) module from Redis Stack. Please refer to Redis Stack docs: https://redis.io/docs/stack/
When I try to install redisearch==2.4 i get the error no such distribution found for redisearch
when I just install redisearch, it updates redis version to 3.5.3
please help

@tylerhutcherson
Copy link
Contributor

Ok so the redis client version fixed the initial error here.

For this one, you don't need to install a different client. You need to run the version of redis that has the search module installed on the database for vector search. (Redis is modular and has different developer capabilities). Did you checkout the link it provided?

Here is a docker command to run the correct flavor of redis:

docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest

@iamadhee
Copy link
Contributor

iamadhee commented May 17, 2023

Hi, I'm also getting the same error. I'm using the below versions of the packages

redis==3.5.3
redisearch==2.1.1

The docker command also didn't actually solve the issue.

Seems there is some dependency conflict between redis and redisearch. redisearch>=2.4 is not available. 2.1.1 is the latest.

@apburton84
Copy link

apburton84 commented May 17, 2023

Hey,

Same issue ...

AttributeError: 'Redis' object has no attribute 'module_list'

The redis client, and redisearch versions are:

redis==3.5.3
redisearch==2.1.1

The docker image

docker run -d --name bot -p 6379:6379 redis/redis-stack-server:latest

With the redis stack server version being redis-stack-server==6.2.12

When executing the command MODULE LIST from the redis cli the list of modules is returned as expected.

This appears to be an API incompatibility with the redis python client version that is pinned to python redisearch i.e. as the error says the redis client does not have the module_list method.

The python redis client documentation for 3.5.3 is sparse on the subject.
https://redis-py.readthedocs.io/en/3.5.3/py-modindex.html

It appears that module_list was introduced in version 4.1.0 of the python redis client.
https://redis-py.readthedocs.io/en/v4.1.0/redis_commands.html?highlight=module_list#redis.commands.core.CoreCommands.module_list

This is a redisearch issues rather than a langchain issues (https://github.com/RediSearch/redisearch-py/blob/master/pyproject.toml)

@tylerhutcherson
Copy link
Contributor

tylerhutcherson commented May 17, 2023

Thanks for looking into that.

The redisearch client library should not be needed here. All search functionality required has been ported to the standard redis Python client.

We need to make sure that any LangChain pin to redisearch is removed in favor of just redis. Will look into this.

cc @hwchase17

@tylerhutcherson
Copy link
Contributor

tylerhutcherson commented May 18, 2023

I can't find anywhere in langchain where the redisearch python client library is invoked or used. Any leads? It's possible that user application code uses redisearch client library and that's causing issue?

https://github.com/RediSearch/redisearch-py (this is deprecated now)

@iamadhee
Copy link
Contributor

No, it's just that the error message suggests the user to install redisearch (>=2.4), I'm fixing that in the new PR

https://github.com/hwchase17/langchain/blob/1ed4228822498fd58d33d377572af0821c496b20/langchain/vectorstores/redis.py#LL59C35-L59C35

@nickstreletskij
Copy link

Still not working

@bhanu-Bigdata
Copy link

still not working

@shubh207
Copy link

Can anybody suggest a solution for this issue ..

@dosubot dosubot bot mentioned this issue Sep 12, 2023
14 tasks
@anmolagrwl
Copy link

Still facing the same issue while using redis-stack-server docker container:

Here is the full trace.

rds = Redis.from_texts(
          ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/redis/base.py", line 497, in from_texts
    instance, _ = cls.from_texts_return_keys(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/redis/base.py", line 414, in from_texts_return_keys
    instance = cls(
               ^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain/vectorstores/redis/base.py", line 280, in __init__
    check_redis_module_exist(redis_client, REDIS_REQUIRED_MODULES)
  File "/usr/local/lib/python3.11/site-packages/langchain/utilities/redis.py", line 49, in check_redis_module_exist
    installed_modules = client.module_list()
                        ^^^^^^^^^^^^^^^^^^
AttributeError: 'Redis' object has no attribute 'module_list'

Was really looking forward to using Redis. Seems this issue has been there for a while. I will have to look into other vector DB options soon.

@shanshanRT
Copy link

still not working..

@GhaithDek
Copy link

these versions resolved my problem:

pip install redis==4.5.4 redisearch==2.0.0

let me know,
thanks

@tylerhutcherson
Copy link
Contributor

FYI there is no dependency on redisearch; the client library here. Base redis is all that's needed from a client standpoint.

You need to make sure search/query featured are enabled on your database... which is built-in if using the free Redis Stack docker image or Redis Enterprise.

@koorukuroo
Copy link

You guys all need to switch to Redis Stack, not just Redis.

docker run -d --name redis-stack -p 6379:6379 redis/redis-stack:latest

@sahilshaikh89
Copy link

I was facing the same issue with Conda as my package manager.
langchain==0.3.4
langchain-community==0.3.3
redis==3.5.3

I was able to resolve the issue by installing langchain-redis==0.1.1 integration package which is mentioned on langchain 0.3 release notes. However, Conda doesn't have that langchain-redis package on any of the channels so ended up installing using pip. I know its a mess to use two package managers in the same environment, but this resolved my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.