Getting ModuleNotFoundError: No module named 'xxxxxx'

I am installing a custom app in ERPNext 13 using following commands.

bench install-app CustomApp
bench migrate
bench restart

Now when I go to login page and refresh page I get the error

Getting ModuleNotFoundError: No module named 'xxxxxx'

What must be the problem and how to solve it?

Regards,

I keep getting this error message even if I create a new custom app.

Here are the commands that I issued to create a new app and its output.

yogesh@vmi934079:~/erp13$ bench new-app mm
App Title (default: Mm):
App Description: mm
App Publisher: mm
App Email: mm@mm.com
App Icon (default 'octicon octicon-file-directory'):
App Color (default 'grey'):
App License (default 'MIT'):
'mm' created at /home/yogesh/erp13/apps/mm
Installing mm
$ /home/yogesh/erp13/env/bin/python -m pip install --quiet --upgrade -e /home/yogesh/erp13/apps/mm
$ bench build --app mm
βœ” Application Assets Linked

yarn run v1.22.19
$ FRAPPE_ENV=production node rollup/build.js --app mm
Production mode
βœ” Built js/moment-bundle.min.js
βœ” Built js/libs.min.js
Done in 1.04s.
yogesh@vmi934079:~/erp13$ bench install-app mm

Installing mm...
yogesh@vmi934079:~/erp13$ bench migrate
Migrating erp13
Updating DocTypes for frappe        : [========================================] 100%
Updating DocTypes for erpnext       : [========================================] 100%
Updating Dashboard for frappe
Updating Dashboard for erpnext
Updating Dashboard for mm
Updating customizations for Address
Updating customizations for Contact
Building search index for erp13
Retrieving Routes                   : [========================================] 100%
Building Index                      : [========================================] 100%
yogesh@vmi934079:~/erp13$ bench restart
yogesh@vmi934079:~/erp13$

After this when I refresh my browser I get the error.


ModuleNotFoundError

ModuleNotFoundError: No module named 'mm'
Traceback (most recent call last)

    File "/home/yogesh/erp13/apps/frappe/frappe/app.py", line 78, in application

    response = frappe.website.render.render()

    File "/home/yogesh/erp13/apps/frappe/frappe/website/render.py", line 54, in render

    elif is_static_file(path):

    File "/home/yogesh/erp13/apps/frappe/frappe/website/render.py", line 127, in is_static_file

    file_path = frappe.get_app_path(app, "www") + "/" + path

    File "/home/yogesh/erp13/apps/frappe/frappe/__init__.py", line 1227, in get_app_path

    return get_pymodule_path(app_name, *joins)

    File "/home/yogesh/erp13/apps/frappe/frappe/__init__.py", line 1244, in get_pymodule_path

    return os.path.join(os.path.dirname(get_module(scrub(modulename)).__file__ or ""), *joins)

    File "/home/yogesh/erp13/apps/frappe/frappe/__init__.py", line 1200, 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 "<frozen importlib._bootstrap>", line 1050, in _gcd_import

     

    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load

     

    File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked

     

    During handling of the above exception, another exception occurred:
    File "/home/yogesh/erp13/apps/frappe/frappe/middlewares.py", line 18, in __call__

    return super(StaticDataMiddleware, self).__call__(environ, start_response)

    File "/home/yogesh/erp13/env/lib/python3.10/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__

    return self.app(environ, start_response)

    File "/home/yogesh/erp13/env/lib/python3.10/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__

    return self.app(environ, start_response)

    File "/home/yogesh/erp13/env/lib/python3.10/site-packages/werkzeug/local.py", line 231, in application

    return ClosingIterator(app(environ, start_response), self.cleanup)

    File "/home/yogesh/erp13/env/lib/python3.10/site-packages/werkzeug/wrappers/base_request.py", line 237, in application

    resp = f(*args[:-2] + (request,))

    File "/home/yogesh/erp13/apps/frappe/frappe/app.py", line 90, in application

    response = handle_exception(e)

    File "/home/yogesh/erp13/apps/frappe/frappe/app.py", line 290, in handle_exception

    response = frappe.website.render.render("message", http_status_code=http_status_code)

    File "/home/yogesh/erp13/apps/frappe/frappe/website/render.py", line 54, in render

    elif is_static_file(path):

    File "/home/yogesh/erp13/apps/frappe/frappe/website/render.py", line 127, in is_static_file

    file_path = frappe.get_app_path(app, "www") + "/" + path

    File "/home/yogesh/erp13/apps/frappe/frappe/__init__.py", line 1227, in get_app_path

    return get_pymodule_path(app_name, *joins)

    File "/home/yogesh/erp13/apps/frappe/frappe/__init__.py", line 1244, in get_pymodule_path

    return os.path.join(os.path.dirname(get_module(scrub(modulename)).__file__ or ""), *joins)

    File "/home/yogesh/erp13/apps/frappe/frappe/__init__.py", line 1200, 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 "<frozen importlib._bootstrap>", line 1050, in _gcd_import

     

    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load

     

    File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked

     

    ModuleNotFoundError: No module named 'mm'

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

    dump() shows all variables in the frame
    dump(obj) dumps all that's known about the object

Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter.

What to do and how to solve this problem?

Regards,

You need to include the --site (site_name) after bench command

bench --site {site name} install-app CustomApp

1 Like

@centaur,

Thanks for your reply. But it seems the problem is somewhere else.

Let me try and explain.

It so happens that if I give the commands.

bench new-app mm
bench restart

Now when I refresh the Browser I get PipeError module not found. I don’t understand as to why?

Actually I have not yet installed the app in Site still I start getting this error.

Even it uninstall the app using.

bench uninstall-app mm
bench migrate
bench restart

It still give the same error of ModuleNotFound.

But if I remove the custom app using.

bench remove mm
bench restart

Then this error goes away and things start working normally.

Can you give me some ideas as to what must be the problem here?

Regards,

1 Like

is development mode set to 1 in site_config.json ?

No it is not set.

I have not enabled development mode on the VPS.

Regards,