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

cannot import name 'clear_defaults_cache' #11547

Closed
centaur78 opened this issue Sep 22, 2020 · 7 comments
Closed

cannot import name 'clear_defaults_cache' #11547

centaur78 opened this issue Sep 22, 2020 · 7 comments
Labels

Comments

@centaur78
Copy link

hi @netchampfaris

I am getting the below error while doing bench update due to this PR #11285

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  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.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.6/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.6/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.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.6/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/site.py", line 280, in migrate
    from frappe.migrate import migrate
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 16, in <module>
    from frappe.cache_manager import clear_global_cache
  File "/home/frappe/frappe-bench/apps/frappe/frappe/cache_manager.py", line 7, in <module>
    import frappe.defaults
  File "/home/frappe/frappe-bench/apps/frappe/frappe/defaults.py", line 7, in <module>
    from frappe.cache_manager import clear_defaults_cache, common_default_keys
ImportError: cannot import name 'clear_defaults_cache'
@centaur78 centaur78 added the bug label Sep 22, 2020
@intrepidtechnology
Copy link

intrepidtechnology commented Sep 22, 2020

Hi @centaur78 and @netchampfaris

I'm running into the exact same.

Environment:

  • Debian 10
  • Python 3.7

Here's the log:

Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main 
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/support/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 99, in 
    main()
  File "/home/support/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/support/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/support/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/support/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/support/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/support/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/support/frappe-bench/env/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/support/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/support/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 26, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/support/frappe-bench/apps/frappe/frappe/commands/site.py", line 280, in migrate
    from frappe.migrate import migrate
  File "/home/support/frappe-bench/apps/frappe/frappe/migrate.py", line 16, in 
    from frappe.cache_manager import clear_global_cache
  File "/home/support/frappe-bench/apps/frappe/frappe/cache_manager.py", line 7, in 
    import frappe.defaults
  File "/home/support/frappe-bench/apps/frappe/frappe/defaults.py", line 7, in 
    from frappe.cache_manager import clear_defaults_cache, common_default_keys
ImportError: cannot import name 'clear_defaults_cache' from 'frappe.cache_manager' (/home/support/frappe-bench/apps/frappe/frappe/cache_manager.py)

Here is the error that appears in the browser:

frappe.exceptions.DoesNotExistError

frappe.exceptions.DoesNotExistError: Web Template Standard Navbar not found
Traceback (most recent call last)

    File "/home/support/frappe-bench/apps/frappe/frappe/app.py", line 54, in application

    init_request(request)

    File "/home/support/frappe-bench/apps/frappe/frappe/app.py", line 133, in init_request

    raise frappe.SessionStopped('Session Stopped')

    During handling of the above exception, another exception occurred:
    File "/home/support/frappe-bench/apps/frappe/frappe/website/render.py", line 50, in render

    data = render_page_by_language(path)

    File "/home/support/frappe-bench/apps/frappe/frappe/website/render.py", line 177, in render_page_by_language

    return render_page(path)

    File "/home/support/frappe-bench/apps/frappe/frappe/website/render.py", line 193, in render_page

    return build(path)

    File "/home/support/frappe-bench/apps/frappe/frappe/website/render.py", line 200, in build

    return build_page(path)

    File "/home/support/frappe-bench/apps/frappe/frappe/website/render.py", line 223, in build_page

    html = frappe.get_template(context.template).render(context)

    File "/home/support/frappe-bench/env/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render

    self.environment.handle_exception()

    File "/home/support/frappe-bench/env/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception

    reraise(*rewrite_traceback_stack(source=source))

    File "/home/support/frappe-bench/env/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise

    raise value.with_traceback(tb)

    File "/home/support/frappe-bench/apps/frappe/frappe/www/message.html", line 1, in top-level template code

    {% extends "templates/web.html" %}

    File "/home/support/frappe-bench/apps/frappe/frappe/templates/web.html", line 1, in top-level template code

    {% extends base_template_path %}

    File "/home/support/frappe-bench/apps/frappe/frappe/templates/base.html", line 57, in top-level template code

    window.dev_server = {{ dev_server }};

    File "/home/support/frappe-bench/apps/frappe/frappe/templates/base.html", line 58, in block "navbar"

    window.socketio_port = {{ (frappe.socketio_port or 'null') }};

    File "/home/support/frappe-bench/env/lib/python3.7/site-packages/jinja2/sandbox.py", line 462, in call

    return __context.call(__obj, *args, **kwargs)

    File "/home/support/frappe-bench/apps/frappe/frappe/utils/jinja.py", line 199, in web_block

    return web_blocks([options])

    File "/home/support/frappe-bench/apps/frappe/frappe/utils/jinja.py", line 224, in web_blocks

    out = get_web_blocks_html(web_blocks)

    File "/home/support/frappe-bench/apps/frappe/frappe/website/doctype/web_page/web_page.py", line 211, in get_web_blocks_html

    web_template = frappe.get_cached_doc('Web Template', block.web_template)

    File "/home/support/frappe-bench/apps/frappe/frappe/__init__.py", line 743, in get_cached_doc

    doc = get_doc(*args, **kwargs)

    File "/home/support/frappe-bench/apps/frappe/frappe/__init__.py", line 786, in get_doc

    doc = frappe.model.document.get_doc(*args, **kwargs)

    File "/home/support/frappe-bench/apps/frappe/frappe/model/document.py", line 75, in get_doc

    return controller(*args, **kwargs)

    File "/home/support/frappe-bench/apps/frappe/frappe/model/document.py", line 113, in __init__

    self.load_from_db()

    File "/home/support/frappe-bench/apps/frappe/frappe/model/document.py", line 156, in load_from_db

    frappe.throw(_("{0} {1} not found").format(_(self.doctype), self.name), frappe.DoesNotExistError)

    File "/home/support/frappe-bench/apps/frappe/frappe/__init__.py", line 405, in throw

    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide)

    File "/home/support/frappe-bench/apps/frappe/frappe/__init__.py", line 384, in msgprint

    _raise_exception()

    File "/home/support/frappe-bench/apps/frappe/frappe/__init__.py", line 332, in _raise_exception

    raise raise_exception(msg)

Finally, a screenshot of same:
Screenshot_20200922_135008

@netchampfaris
Copy link
Contributor

netchampfaris commented Sep 22, 2020

Those files were not changed in this PR #11285.

I was able to migrate my site after my PR was merged. This issue is unrelated but I sent a fix.

#11552

@centaur78
Copy link
Author

Thanks @netchampfaris

Just bench updated the PR #11552 , issue resolved.

@intrepidtechnology
Copy link

Thanks @netchampfaris, it's working perfectly now.

@kimsreng
Copy link

I still have the same issue with the development branch. What command can i use to fix it?

@centaur78
Copy link
Author

I still have the same issue with the development branch. What command can i use to fix it?

just do "bench update"

@kimsreng
Copy link

Yeah I did it but the problem still persists.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants