Changing from master to staging branch: Error cannot import name Database

Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/keerthi/frappe/computer_care/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/keerthi/frappe/computer_care/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/keerthi/frappe/computer_care/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/keerthi/frappe/computer_care/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/keerthi/frappe/computer_care/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/keerthi/frappe/computer_care/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/keerthi/frappe/computer_care/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/keerthi/frappe/computer_care/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/keerthi/frappe/computer_care/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/keerthi/frappe/computer_care/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/keerthi/frappe/computer_care/frappe-bench/apps/frappe/frappe/commands/site.py”, line 215, in migrate
from frappe.migrate import migrate
File “/home/keerthi/frappe/computer_care/frappe-bench/apps/frappe/frappe/migrate.py”, line 17, in
import frappe.utils.help
File “/home/keerthi/frappe/computer_care/frappe-bench/apps/frappe/frappe/utils/help.py”, line 11, in
from frappe.database import Database
ImportError: cannot import name Database

Hi, please check sites directory and check your sitename then run in the frappe-bench folder

bench use yoursitename

I Fixed it.

If you are shifting between branches and facing this error (I face this error when I switch to develop and then back to staging-fixes), run the following command

if you are in frappe-bench folder

frappe-bench > cd apps/frappe
frappe-bench/apps/frappe > find . -name “*.pyc” -exec rm -f {} ;

Then
bench build & migrate. Working fine.