Error after Bench Update No module named 'redis.commands'

I had been using Frappe WIKI on two different applications, about a month a go (did not write exact date) the pages where unaccessible, i thought it would be corrected on next install. Now i had to totally uninstall the app (bench --site erpinstallation.com uninstall-app wiki --force), but when trying to reinstall i get the next error:

Updating DocTypes for wiki : [============ ] 30%An error occurred while installing wiki: Module import failed for Wiki Space, the DocType you’re trying to open might be deleted.
Error: No module named ‘redis.commands’
Traceback (most recent call last):
File “apps/frappe/frappe/modules/utils.py”, line 245, in load_doctype_module
doctype_python_modules[key] = frappe.get_module(module_name)
File “apps/frappe/frappe/init.py”, line 1327, in get_module
return importlib.import_module(modulename)
File “/usr/lib/python3.10/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 1006, in _find_and_load_unlocked
File “”, line 688, in _load_unlocked
File “”, line 883, in exec_module
File “”, line 241, in _call_with_frames_removed
File “apps/wiki/wiki/wiki/doctype/wiki_space/wiki_space.py”, line 11, in
from wiki.wiki.doctype.wiki_page.search import drop_index, rebuild_index_in_background
File “apps/wiki/wiki/wiki/doctype/wiki_page/search.py”, line 8, in
from redis.commands.search.field import TextField
ModuleNotFoundError: No module named ‘redis.commands’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “apps/frappe/frappe/commands/site.py”, line 416, in install_app
_install_app(app, verbose=context.verbose, force=force)
File “apps/frappe/frappe/installer.py”, line 294, in install_app
sync_for(name, force=force, reset_permissions=True)
File “apps/frappe/frappe/model/sync.py”, line 81, in sync_for
import_file_by_path(
File “apps/frappe/frappe/modules/import_file.py”, line 145, in import_file_by_path
import_doc(
File “apps/frappe/frappe/modules/import_file.py”, line 242, in import_doc
doc.insert()
File “apps/frappe/frappe/model/document.py”, line 285, in insert
self.run_post_save_methods()
File “apps/frappe/frappe/model/document.py”, line 1082, in run_post_save_methods
self.run_method(“on_update”)
File “apps/frappe/frappe/model/document.py”, line 914, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 1264, in composer
return composed(self, method, *args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 1246, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “apps/frappe/frappe/model/document.py”, line 911, in fn
return method_object(*args, **kwargs)
File “apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 409, in on_update
self.run_module_method(“on_doctype_update”)
File “apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 494, in run_module_method
module = load_doctype_module(self.name, self.module)
File “apps/frappe/frappe/modules/utils.py”, line 249, in load_doctype_module
raise ImportError(msg) from e
ImportError: Module import failed for Wiki Space, the DocType you’re trying to open might be deleted.
Error: No module named ‘redis.commands’

I have traced the error to redis.commands and i have reviewed the redis installation. These are some additional screenshots

erpnext@localhost:~$ python3 -m pip install --upgrade redis
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: redis in /usr/local/lib/python3.10/dist-packages (4.5.4)
Requirement already satisfied: async-timeout>=4.0.2 in /usr/local/lib/python3.10/dist-packages (from redis) (4.0.2)

erpnext@localhost:~/frappe-bench$ pip show redis
Name: redis
Version: 4.5.4
Summary: Python client for Redis database and key-value store
Home-page: GitHub - redis/redis-py: Redis Python Client
Author: Redis Inc.
Author-email: oss@redis.com
License: MIT
Location: /usr/local/lib/python3.10/dist-packages
Requires: async-timeout
Required-by:

erpnext@localhost:~/frappe-bench$ sudo systemctl status redis-server.service
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2023-04-24 22:36:11 UTC; 1h 21min ago
Docs: https://redis.io/docs/,
man:redis-server(1)
Main PID: 901 (redis-server)
Status: “Ready to accept connections”
Tasks: 5 (limit: 4530)
Memory: 4.9M
CPU: 6.500s
CGroup: /system.slice/redis-server.service
└─901 “/usr/bin/redis-server 127.0.0.1:6379” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “”

Apr 24 22:36:10 localhost systemd[1]: Starting Advanced key-value store…
Apr 24 22:36:11 localhost systemd[1]: Started Advanced key-value store.

erpnext@localhost:~/frappe-bench$ pip3 list | grep redis
redis 4.5.4

I am by no means a python expert or developer, but i tried all solutions that were posted previously (mix of develop and V14 versions, unexisting redis installation,…), i do not know if the redis version available is the correct for WIKI.

I have always run production versions on my installations, as far as i could tell never installed a develop branch.

I am temporarily running the installations without the WIKI app, and would love to get back using it, but if it is not possible i would move to another solution. If WIKI is no longer compatible with the current erpnext/frappe release it would be great to know

Regards and thank you for any help

Luis Montanaro

Hi,

I can sort of reproduce the error , without installing the app.

In a terminal try python3, then import sys; import redis; then from redis.commands.json.path import Path. Is there an error?

Now try the same commands using bench --site <site-name> console . Is there an error message ?
In both python shells type: sys.executable to see the path to the interpreter.

I’m not a python expert either but maybe this will help someone better versed help out.

thank you for your prompt answer, i ran the commands and get these results, it seems that the bench console has a problem with redis.commands

erpnext@localhost:~/frappe-bench$ python3

Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux

Type “help”, “copyright”, “credits” or “license” for more information.

import sys

import redis

from redis.commands.json.path import Path

erpnext@localhost:~/frappe-bench$ bench --site myerp.com console

Apps in this namespace:

frappe, payments, erpnext, hrms, meetings, strategic_planning, project_management, erpnext_custom, planning

In [1]: python3


NameError Traceback (most recent call last)

File :1, in <cell line: 1>()

----> 1 python3

NameError: name ‘python3’ is not defined

In [2]: import sys

In [3]: import redis

In [4]: from redis.commands.json.path import Path


ModuleNotFoundError Traceback (most recent call last)

File :1, in <cell line: 1>()

----> 1 from redis.commands.json.path import Path

ModuleNotFoundError: No module named ‘redis.commands’

In [5]:

Thanks for your help

In either shell the command: print(sys.executable); print(sys.version); I don’t know if that will help or not. I see the issue has been opened on github as well.

These are the results i am getting, i keep getting the No module named ‘redis.commands’ error on the console

erpnext@localhost:~/frappe-bench$ python3

Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux

Type “help”, “copyright”, “credits” or “license” for more information.

import sys
import redis
from redis.commands.json.path import Path
print(sys.executable)
/usr/bin/python3
print(sys.version)
3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]

erpnext@localhost:~/frappe-bench$ bench --site myerp.com console

Apps in this namespace:

frappe, payments, erpnext, hrms, meetings, strategic_planning, project_management, erpnext_custom, planning

In [1]: python3


NameError Traceback (most recent call last)

File :1, in <cell line: 1>()

----> 1 python3

NameError: name ‘python3’ is not defined

In [2]: import sys

In [3]: import redis

In [4]: from redis.commands.json.path import Path


ModuleNotFoundError Traceback (most recent call last)

File :1, in <cell line: 1>()

----> 1 from redis.commands.json.path import Path

ModuleNotFoundError: No module named ‘redis.commands’

In [5]: print(sys.executable)

/home/erpnext/frappe-bench/env/bin/python

In [6]: print(sys.version)

3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]

In [7]:

The issue was originated on the WIKI app changing, it was solved temporarily by using a different branch, for me redisearch-v14 branch made the trick, regards.

How to solve this issue?

I’m also trying to get the Wiki app installed and working on 14 and getting this error.