Error when trying to run frappe commands on Docker install

Hi ,

I encountered the following error when trying to run the clear-cache command on a Docker install

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 99, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 26, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py", line 58, in clear_cache
    frappe.clear_cache()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 621, in clear_cache
    frappe.cache_manager.clear_user_cache()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/cache_manager.py", line 48, in clear_user_cache
    clear_global_cache()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/cache_manager.py", line 61, in clear_global_cache
    frappe.setup_module_map()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1075, in setup_module_map
    for module in get_module_list(app):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 937, in get_module_list
    return get_file_items(os.path.join(os.path.dirname(get_module(app_name).__file__), "modules.txt"))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 895, in get_module
    return importlib.import_module(modulename)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'erpnext'
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 18, in <module>
    [sys.executable, bench_helper, 'frappe'] + sys.argv[1:],
  File "/usr/local/lib/python3.7/subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/frappe/frappe-bench/env/bin/python', '/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py', 'frappe', '--site', 'my.domain.org', 'clear-cache']' returned non-zero exit status 1.

Any ideas ?

Kind regards

Have you mounted the sites volume if you’re running the command in new container with docker run?

What is in your sites/app.txt?

Hi @revant_one

Thanks for responding. It’s an existing setup where site is already running. I just ran the command to clear cache from the terminal as shown below:

docker run \
    -v my-project_sites-vol:/home/frappe/frappe-bench/sites \
    --network webproxy \
    --user frappe \
    frappe/frappe-worker:version-13-beta bench --site my.domain.org clear-cache

Where is the sites/app.txt file located pls?

It’s in “my-project_sites-vol” mounted inside container at /home/frappe/frappe-bench/sites.

refer this to edit it if needed, https://github.com/frappe/frappe_docker/blob/develop/docs/site-operations.md#edit-configs

Following might be your real problem:

use frappe/erpnext-worker image instead of frappe/frappe-worker image.

Hi @revant_one

This actually solved the issue… thanks a million!

Cheers