Installing Custom app - Module Import Failed sms_settings

Hi,
I am trying to install app in my local server which is already working perfectly in live server,
but facing below error:

ImportError: Module import failed for Internals (xyz.xyz.doctype.Internals.Internals Error: No module named sms_settings.sms_settings)

Full trace

frappe@erpnext:~/frappe-bench$ bench --site erpnext.vm install-app xyz

Installing xyz...
Updating DocTypes for xyz     : [===================                     ]Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, 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/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 94, 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/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/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/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 160, in install_app
    _install_app(app, verbose=context.verbose)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 141, in install_app
    sync_for(name, force=True, sync_everything=True, verbose=verbose, reset_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/sync.py", line 45, in sync_for
    reset_permissions=reset_permissions, for_sync=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 58, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 131, in import_doc
    doc.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 245, in insert
    self.run_post_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 827, in run_post_save_methods
    self.run_method("on_update")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 702, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 964, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 947, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 696, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 220, in on_update
    self.run_module_method("on_doctype_update")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 273, in run_module_method
    module = load_doctype_module(self.name, self.module)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 178, in load_doctype_module
    raise ImportError('Module import failed for {0} ({1})'.format(doctype, module_name + ' Error: ' + str(e)))
ImportError: Module import failed for Internals (xyz.xyz.doctype.Internals.Internals Error: No module named sms_settings.sms_settings)

Please help!!!

Hi,

You app is using a method in ERPNext/Frappe that is imported from the module “sms_settings”. It seems that the path to this module/method is incorrect in your application.

It is likely due to a modification in ERPNext/Frappe that has not been corrected in your custom application: your custom app needs to be constantly maintained!

You just need to correct your custom app and it should solve your problem.

Hi.

Can you please guide me in small detail what to do for this? I am yet beginner.

And also in general when you say keep maintained, what exactly have to do?

Hi @akashpvtltd,

If you are a beginner, then it would be best to start by reading all the documentation regarding Frappé, its ecosystem and the creation of custom apps:

https://frappe.io/docs/user/en/tutorial

By maintenance, I mean that Frappé and ERPNext are continuously improving and changing. So if you need to have a custom app, you need to keep it updated to the changes brought to the framework else some links will soon be broken (as in your example).

If the functionality in your custom app is general enough, it is best to submit it to the core model so that you don’t have to do the maintenance alone.

As for your specific case, you need to check the python file associated with your Internals doctype. You will see the link to the SMS settings module you are trying to import and you need to correct it with the new path to that module in Frappe. It is now located in ‘frappe.core.doctype.sms_settings’

Good luck!

Hi again @chdecultot

Based on your post finally I figured out what has to be done (took 5-6 hours).

I changed doctype getting error’s py file and change path for sms_settings to frappe which worked excellent.

But I cannot understand logic of maintain
 so here is my question:

  1. On v8 of ERPNext & Frappe custom app was working perfectly because sms_settings was part of ERPNext and that configuration on that version is correct.

  2. But installing my custom app on updated ERPNext and Frappe doesn’t accept installing app because it could not find sms_settings in source-ERPNext.

  3. But when I installed v8 of Frappe & ERPNext where my app worked perfectly and then update both in which my apps keep working even after update.

So on point 3, What is happening? After Update my app should not working, but it keeps working. Why?

Thanks!!!

Good question
 it may be a cache issue but for sure your app will break at some point if the path is incorrect :wink:

At least you managed to fix it and that’s the best news! :slight_smile:

1 Like