ModuleNotFoundError: No module named 'redis.commands'

Hello, I am trying to install erpnext v14 on my system, I can’t seem to get redis.commands module to install, I have tried to reinstall it multiple times to no avail and I have tried the solutions from other posts and they don’t work for me, if anyone can help it is greatly appreciated.

here is the output after trying to get erpnext. Note: I get the same missing module error when doing bench start

 bench get-app erpnext --branch develop
A directory for the application 'erpnext' already exists. Do you want to continue and overwrite it? [y/N]: y
INFO: App moved from apps/erpnext to archived/apps/erpnext-2022-10-25_1
Getting erpnext
$ git clone https://github.com/frappe/erpnext.git --branch develop --depth 1 --origin upstream
Cloning into 'erpnext'...
remote: Enumerating objects: 4897, done.
remote: Counting objects: 100% (4897/4897), done.
remote: Compressing objects: 100% (4159/4159), done.
remote: Total 4897 (delta 967), reused 2296 (delta 508), pack-reused 0
Receiving objects: 100% (4897/4897), 17.17 MiB | 9.09 MiB/s, done.
Resolving deltas: 100% (967/967), done.
Ignoring dependencies of erpnext. To install dependencies use --resolve-deps
Installing erpnext
$ /home/marek/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/marek/frappe-bench/apps/erpnext 
$ yarn install
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 0.52s.
$ bench build --app erpnext
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/marek/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 104, in <module>
    main()
  File "/home/marek/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 19, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/marek/frappe-bench/apps/frappe/frappe/commands/utils.py", line 57, in build
    frappe.init("")
  File "/home/marek/frappe-bench/apps/frappe/frappe/__init__.py", line 248, in init
    setup_module_map()
  File "/home/marek/frappe-bench/apps/frappe/frappe/__init__.py", line 1505, in setup_module_map
    _cache = cache()
  File "/home/marek/frappe-bench/apps/frappe/frappe/__init__.py", line 362, in cache
    from frappe.utils.redis_wrapper import RedisWrapper
  File "/home/marek/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 7, in <module>
    from redis.commands.search import Search
ModuleNotFoundError: No module named 'redis.commands'
ERROR: 
Traceback (most recent call last):
  File "/home/marek/.local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 127, in cli
    bench_command()
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/commands/make.py", line 159, in get_app
    get_app(
  File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 432, in get_app
    app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 230, in install
    install_app(
  File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 574, in install_app
    build_assets(bench_path=bench_path, app=app)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/bench.py", line 330, in build_assets
    exec_cmd(command, cwd=bench_path, env={"BENCH_DEVELOPER": "1"})
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/__init__.py", line 155, in exec_cmd
    raise CommandFailedError
bench.exceptions.CommandFailedError
INFO: A newer version of bench is available: 5.14.3 → 5.14.4

EDIT: I could not find the problem and since my system was fairly new, I went ahead and reinstalled ubuntu 22.04 and frappe-bench. I do not have the problem anymore but I do not know how this problem can be fixed properly.

Try to use version-14 branch, it seems there is a bug in develop branch

bench get-app erpnext --branch version-14

Gives the same error, I was trying to use version-14 branch initially and tried switching because of another solution on this forum. It just happens that this output is from the develop branch but it gives the same result unfortunately.

Yesterday, I tried to install erpnext develop branch and gave the same error
then switched it to version-14 and worked

Here it is with version-14, same error

$ bench get-app erpnext --branch version-14
A directory for the application 'erpnext' already exists. Do you want to continue and overwrite it? [y/N]: y
INFO: App moved from apps/erpnext to archived/apps/erpnext-2022-10-25_2
Getting erpnext
$ git clone https://github.com/frappe/erpnext.git --branch version-14 --depth 1 --origin upstream
Cloning into 'erpnext'...
remote: Enumerating objects: 4892, done.
remote: Counting objects: 100% (4892/4892), done.
remote: Compressing objects: 100% (4151/4151), done.
remote: Total 4892 (delta 971), reused 2268 (delta 510), pack-reused 0
Receiving objects: 100% (4892/4892), 17.16 MiB | 7.18 MiB/s, done.
Resolving deltas: 100% (971/971), done.
Ignoring dependencies of erpnext. To install dependencies use --resolve-deps
Installing erpnext
$ /home/marek/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/marek/frappe-bench/apps/erpnext 
$ yarn install
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 0.56s.
$ bench build --app erpnext
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/marek/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 104, in <module>
    main()
  File "/home/marek/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 19, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/marek/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/marek/frappe-bench/apps/frappe/frappe/commands/utils.py", line 57, in build
    frappe.init("")
  File "/home/marek/frappe-bench/apps/frappe/frappe/__init__.py", line 248, in init
    setup_module_map()
  File "/home/marek/frappe-bench/apps/frappe/frappe/__init__.py", line 1505, in setup_module_map
    _cache = cache()
  File "/home/marek/frappe-bench/apps/frappe/frappe/__init__.py", line 362, in cache
    from frappe.utils.redis_wrapper import RedisWrapper
  File "/home/marek/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 7, in <module>
    from redis.commands.search import Search
ModuleNotFoundError: No module named 'redis.commands'
ERROR: 
Traceback (most recent call last):
  File "/home/marek/.local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 127, in cli
    bench_command()
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/commands/make.py", line 159, in get_app
    get_app(
  File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 432, in get_app
    app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 230, in install
    install_app(
  File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 574, in install_app
    build_assets(bench_path=bench_path, app=app)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/bench.py", line 330, in build_assets
    exec_cmd(command, cwd=bench_path, env={"BENCH_DEVELOPER": "1"})
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/__init__.py", line 155, in exec_cmd
    raise CommandFailedError
bench.exceptions.CommandFailedError
INFO: A newer version of bench is available: 5.14.3 → 5.14.4

Please check if the Redis server is running or not.

I think the error is because the server is not running on the system.

Regards,

Yes it is active.

$ sudo systemctl status redis
● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-10-25 07:19:02 EDT; 5h 59min ago
       Docs: http://redis.io/documentation,
             man:redis-server(1)
   Main PID: 1146 (redis-server)
     Status: "Ready to accept connections"
      Tasks: 5 (limit: 17757)
     Memory: 5.4M
        CPU: 39.786s
     CGroup: /system.slice/redis-server.service
             └─1146 "/usr/bin/redis-server 127.0.0.1:6379" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Oct 25 07:18:59 rg-server systemd[1]: Starting Advanced key-value store...
Oct 25 07:19:02 rg-server systemd[1]: Started Advanced key-value store.

Hi,

Can you try installing redis from pip and try again?

Try

bench pip install redis

or if you are in the bench folder, try

env/bin/pip install redis

Hello! I have reinstalled Ubuntu and started over and that fixed the problem.

However I did try to install with pip3 before i went down the reinstalling route and it did not resolve the problem.

2 Likes