ModuleNotFoundError: No module named 'frappe.core.api'


Migration from V12 to 13 went well. But once completed, and trying to submit any document I am getting this error “ModuleNotFoundError: No module named ‘frappe.core.api’” on the web interface. Could not find any help online. Anyone please help.


May we know how the migration was performed? Steps and commands?


Long process short story:

  1. Install fresh 13
  2. Backup 12 DB from the old sever with “bench backup with files”
  3. Copy the files no the new server
  4. Restore 12 DB to new 13 with “bench restore with files”
  5. migrate using “bench --site sitename migrate”
  6. There will be many DB errors during step 5. Manually updated the entries in the new server DB as required referring the V13 DB.
  7. repeat step 5 and 6 until the migration is successful
  8. do “bench update” and should be run without errors

Anyone encountered this error, please help.

In general, to update to a new version , one may use the steps found here:

bench switch-to-branch version-13 frappe erpnext --upgrade
bench update
bench build

There may be other steps or options to the above commands that will help as well, for example bench update --patch .

@smino, thank you for the guide.
Unfortunately these didn’t work. All of the above mentioned did run without any errors. Still having the same issue.

There are no errors captured in the logs during submitting any docs (Quotation, Sales Invoice or any other docs.) Only error pops up is in the web page itself

The detailed error copied from web page is below:

App Versions

	"erpnext": "13.46.1",
	"frappe": "13.49.2",
	"ksa_vat": "0.0.1",
	"pdf_on_submit": "13.2"


Form/Sales Invoice/CBX-SINV-00517


Traceback (most recent call last):
  File "apps/frappe/frappe/", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/", line 38, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/", line 76, in execute_cmd
    return, **frappe.form_dict)
  File "apps/frappe/frappe/", line 1473, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/", line 22, in savedocs
  File "apps/frappe/frappe/model/", line 1020, in submit
    return self._submit()
  File "apps/frappe/frappe/model/", line 1009, in _submit
  File "apps/frappe/frappe/model/", line 312, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/", line 366, in _save
  File "apps/frappe/frappe/model/", line 1090, in run_post_save_methods
  File "apps/frappe/frappe/model/", line 943, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/", line 1261, in composer
  File "apps/frappe/frappe/", line 1463, in get_attr
    return getattr(get_module(modulename), methodname)
  File "apps/frappe/frappe/", line 1205, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python3.10/importlib/", 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 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "apps/pdf_on_submit/pdf_on_submit/", line 22, in <module>
    from frappe.core.api.file import create_new_folder
ModuleNotFoundError: No module named 'frappe.core.api'

Request Data

	"type": "POST",
	"args": {
		"doc": "{\"name\":\"CBX-SINV-00517\",\

"invoice_portion\":100,\"discount\":0,\"payment_amount\":402.5,\"outstanding\":402.5,\"paid_amount\":0,\"discounted_amount\":0,\"base_payment_amount\":402.5,\"doctype\":\"Payment Schedule\"}],\"payments\":[],\"sales_team\":[],\"__onload\":{\"make_payment_via_journal_entry\":0}}",
		"action": "Submit"
	"btn": {
		"jQuery224082625244169196481": {
			"events": {
				"click": [
						"type": "click",
						"origType": "click",
						"guid": 3557,
						"namespace": ""
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/"

Response Data

	"exception": "ModuleNotFoundError: No module named 'frappe.core.api'"

Can you post the contents of the site_config.json of your ERPNext site?

Does bench setup requirements complete without error?

Yes, “bench setup requirements” did run without any errors.

bench setup requirements
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade pip
Installing 5 applications...
Installing frappe
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/frappe 
$ yarn install
yarn install v1.22.19
[1/4] Resolving packages...
success Already up-to-date.
$ yarn run snyk-protect
yarn run v1.22.19
$ snyk protect

⚠ WARNING: Snyk protect was removed at 31 March 2022.
Please use '@snyk/protect' package instead: 

Done in 6.02s.
Done in 7.53s.
Installing pdf_on_submit
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/pdf_on_submit 
Installing erpnext
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/erpnext 
$ yarn install
yarn install v1.22.19
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.15s.
Installing payments
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/payments 
Installing ksa_vat
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/ksa_vat


 "db_name": "_884f6bb4043000d2",
 "db_password": "NMDY9gm398D0Tebq",
 "db_type": "mariadb",
 "encryption_key": "w-tO0c_gwq31SC_n83EcB23BvHlwE57ELb9Jxzh0JO8=",
 "maintenance_mode": 0,
 "host_name": "http://localhost",
 "host_name": "",
 "user_type_doctype_limit": {
  "employee_self_service": 10

The only other things I can think of to try are : sudo pip3 install frappe-bench --upgrade

and possibly: bench setup production username , unless you intend to run in develop mode.

@smino, Tried both and ran successfully. Same result, with the web error.

Its very strange that it don’t give any error in the logs.

Any other thoughts???

Finally found it :upside_down_face:

It was due to the app pdf_on_submit, which was causing this error.

removed the app and restarted bench.

@smino, thanks for the support dear.

Looks like pdf_on_submit is at 13.4 , perhaps reinstalling it with the newer version will work?


I had installed pdf_on_submit long back before the KSA_VAT app released. I am not using it currently for my site.

Anyway, could give a try with a clone sometime later.