frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.9k stars 7.34k forks source link

ModuleNotFoundError: No module named 'erpnext' when frappe start_worker and when frappe bench migrate on V14.30.0 #36232

Open dungtc opened 1 year ago

dungtc commented 1 year ago

Information about bug

I got this error when I updated to v14.30.0 version and all dockers run failed when I try to start worker or run bench migrate command

Stacktrace when frappe start_worker on v14.30.0

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, 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.11/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/scheduler.py", line 206, in start_worker
    start_worker(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 223, in start_worker
    with frappe.init_site():
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 341, in __enter__
    init(self.site)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 248, in init
    setup_module_map()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1538, in setup_module_map
    for module in get_module_list(app):
                  ^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1378, 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 1327, in get_module
    return importlib.import_module(modulename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'erpnext'

Stacktrace when frappe bench migrate on v14.30.0

  rv = self.invoke(ctx)
      self = <Group None>
      args = ['frappe', '--site', 'localhost', 'migrate']
      prog_name = 'bench'
      complete_var = None
      standalone_mode = True
      extra = {}
      ctx = <click.core.Context object at 0x7fd222945e50>
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
      self = <Group None>
      ctx = <click.core.Context object at 0x7fd222945e50>
      _process_result = <function MultiCommand.invoke.<locals>._process_result at 0x7fd222961d00>
      args = ['migrate']
      cmd_name = 'frappe'
      cmd = <Group frappe>
      sub_ctx = <click.core.Context object at 0x7fd223ba5f10>
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
      self = <Group frappe>
      ctx = <click.core.Context object at 0x7fd223ba5f10>
      _process_result = <function MultiCommand.invoke.<locals>._process_result at 0x7fd22296e0c0>
      args = []
      cmd_name = 'migrate'
      cmd = <Command migrate>
      sub_ctx = <click.core.Context object at 0x7fd2227dfad0>
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
      self = <Command migrate>
      ctx = <click.core.Context object at 0x7fd2227dfad0>
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
      args = ()
      kwargs = {'skip_failing': False, 'skip_search_index': False}
      self = <click.core.Context object at 0x7fd2227dfad0>
      callback = <function migrate at 0x7fd2227f4900>
      ctx = <click.core.Context object at 0x7fd2227dfad0>
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
      args = ()
      kwargs = {'skip_failing': False, 'skip_search_index': False}
      f = <function migrate at 0x7fd2227f4680>
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
      ctx = <click.core.Context object at 0x7fd2227dfad0>
      args = ()
      kwargs = {'skip_failing': False, 'skip_search_index': False}
      profile = False
      f = <function migrate at 0x7fd2227f45e0>
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 560, in migrate
    ).run(site=site)
      context = {'sites': ['localhost'], 'force': False, 'verbose': False, 'profile': False}
      skip_failing = False
      skip_search_index = False
      activate_by_import = <module 'traceback_with_variables.activate_by_import' from '/home/frappe/frappe-bench/env/lib/python3.11/site-packages/traceback_with_variables/activate_by_import.py'>
      SiteMigration = <class 'frappe.migrate.SiteMigration'>
      site = 'localhost'
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 166, in run
    frappe.init(site=site)
      self = <frappe.migrate.SiteMigration object at 0x7fd22179b790>
      site = 'localhost'
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 248, in init
    setup_module_map()
      site = 'localhost'
      sites_path = '.'
      new_site = False
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1538, in setup_module_map
    for module in get_module_list(app):
      _cache = RedisWrapper<ConnectionPool<Connection<host=10.20.1.11,port=6379,db=0>>>
      app = 'erpnext'
      module = 'event_streaming'
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1378, in get_module_list
    return get_file_items(os.path.join(os.path.dirname(get_module(app_name).__file__), "modules.txt"))
      app_name = 'erpnext'
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1327, in get_module
    return importlib.import_module(modulename)
      modulename = 'erpnext'
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
      name = 'erpnext'
      package = None
      level = 0
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
      name = 'erpnext'
      package = None
      level = 0
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
      name = 'erpnext'
      import_ = <function _gcd_import at 0x7fd2252a3d80>
      module = <object object at 0x7fd2252d8050>
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
      name = 'erpnext'
      import_ = <function _gcd_import at 0x7fd2252a3d80>
      path = None
      parent = ''
      parent_spec = None
      spec = None
builtins.ModuleNotFoundError: No module named 'erpnext'

Module

other

Version

Frappe version v14.30.0 ERPNext version v14.30.0

Installation method

docker

Relevant log output / Stack trace / Full Error Message.

No response

khaledrifa3i commented 1 year ago

i had the same issue while migrating under docker, appreciate any help

hidayatmanusiya commented 1 year ago

Did you try bench build --force

then bench clear-cache

ThanhHung2112 commented 5 months ago

Did you try bench build --force

then bench clear-cache

As Instruction, I'm execute

bench build --force
bench --site hrms.local clear-cache 

# Then
bench --site hrms.local install-app hrms

And the issue still happen