Bench new-site throws Error: No module named ‘pkg_resources’

Hi,

On a new install (Ubuntu 22.04, Python 3.10), trying to run the bench new-site command results in the following error:

ImportError: Module import failed for Dropbox Settings, the DocType you’re trying to open might be deleted.
Error: No module named ‘pkg_resources’

I’ve tried reinstalling setuptools several times but doesn’t seem to solve the issue

Is this a bug ? Any ideas how to get around this please ?

Kind regards,

1 Like

apt-get install pkg-config.

That should be a fix.

Hi @cephas_kamuchira

Thanks for your suggestion. I’ve tried this but the issue persists. Any other suggestions ?

Kind regards,

Even I am facing the same issue

I’m wondering if it’s related to the version of bench. What version do you have ?

We are aware of this issue and are fixing it, this is only happening on v15 as of now.

when is it going to be fix?

Same issue in Ubuntu 24.04.2 LTS , Frappe Framework: v15.99.0

This is currently a blocker for all Frappe v15 instances.

setuptools v82.0.0 removed pkg_resources, which is still required by the Dropbox dependency used in Frappe v15. As a result, any fresh Frappe v15 install fails with ModuleNotFoundError: No module named 'pkg_resources'.
Frappe v16 is not affected because the dropbox dependency was moved to offsite_backups and updated to 12.0.2

There is an existing issue tracking this:
https://github.com/frappe/bench/issues/1698

And an open PR that fixes it by capping setuptools to <82.0.0:
https://github.com/frappe/bench/pull/1699

Until this is merged, all new Frappe v15 setups are broken (there is a temporary workaround mentioned in the issue).

Additional note:
The Dropbox Python SDK itself states:

Important: Make sure you’re using v12.0.2 or newer of this SDK by January 2026 for continued compatibility with the Dropbox API servers.
https://github.com/dropbox/dropbox-sdk-python
https://dropbox.tech/developers/api-server-certificate-changes

So the long-term fix is to make Frappe V15 use a newer version of Dropbox.

IMHO Frappe really should start pinning critical dependencies to not break stable releases.

but same issue coming in v16 as well

It has been fixed, update to the latest v15-hotfix of frappe and v15 of the payments app.

so if installing new site on new server ? will it work properly? am isntalling v15 on ubuntu 22.04

It should ideally, yes.

ok trying

@mihir-kandoi (and the rest of the Frappe Core Team)

We are very unhappy with the communication regarding this issue. A problem of this magnitude should at the very least have been publicly announced. Furthermore, once a fix was available, it should have been clearly communicated. There are multiple GitHub issues and forum posts on this, yet none provide proper notice. Our team spent an entire day developing a solution that, apparently, already existed.

While the proposed solution on the v15-hotfix branch resolves the problem, it effectively forces every Frappe v15 user to upgrade to the newest version of Frappe and ERPNext. We host many instances for multiple companies, and such upgrades cannot be done lightly. Therefore, the linked GitHub fix in Bench (#1699) is absolutely urgent and must be merged to allow a proper resolution for all users.

We strongly urge the team to prioritize this fix and improve communication for critical issues like this in the future.

Installing frappe…
Updating DocTypes for frappe : [================================= ] 82%Traceback (most recent call last):
File “/home/frappe/frappe-folder/apps/frappe/frappe/modules/utils.py”, line 282, in load_doctype_module
doctype_python_modules[key] = frappe.get_module(module_name)
File “/home/frappe/frappe-folder/apps/frappe/frappe/init.py”, line 1454, 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 “”, line 1050, in _gcd_import
File “”, line 1027, in _find_and_load
File “”, line 1006, in _find_and_load_unlocked
File “”, line 688, in _load_unlocked
File “”, line 883, in exec_module
File “”, line 241, in _call_with_frames_removed
File “/home/frappe/frappe-folder/apps/frappe/frappe/integrations/doctype/dropbox_settings/dropbox_settings.py”, line 7, in
import dropbox
File “/home/frappe/frappe-folder/env/lib/python3.10/site-packages/dropbox/init.py”, line 3, in
from dropbox.dropbox_client import ( # noqa: F401 # pylint: disable=unused-import
File “/home/frappe/frappe-folder/env/lib/python3.10/site-packages/dropbox/dropbox_client.py”, line 43, in
from dropbox.session import (
File “/home/frappe/frappe-folder/env/lib/python3.10/site-packages/dropbox/session.py”, line 1, in
import pkg_resources
ModuleNotFoundError: No module named ‘pkg_resources’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/lib/python3.10/runpy.py”, line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/usr/lib/python3.10/runpy.py”, line 86, in _run_code
exec(code, run_globals)
File “/home/frappe/frappe-folder/apps/frappe/frappe/utils/bench_helper.py”, line 114, in
main()
File “/home/frappe/frappe-folder/apps/frappe/frappe/utils/bench_helper.py”, line 20, in main
click.Group(commands=commands)(prog_name=“bench”)
File “/home/frappe/frappe-folder/env/lib/python3.10/site-packages/click/core.py”, line 1442, in call
return self.main(*args, **kwargs)
File “/home/frappe/frappe-folder/env/lib/python3.10/site-packages/click/core.py”, line 1363, in main
rv = self.invoke(ctx)
File “/home/frappe/frappe-folder/env/lib/python3.10/site-packages/click/core.py”, line 1830, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-folder/env/lib/python3.10/site-packages/click/core.py”, line 1830, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/frappe-folder/env/lib/python3.10/site-packages/click/core.py”, line 1226, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/frappe-folder/env/lib/python3.10/site-packages/click/core.py”, line 794, in invoke
return callback(*args, **kwargs)
File “/home/frappe/frappe-folder/apps/frappe/frappe/commands/site.py”, line 113, in new_site
_new_site(
File “/home/frappe/frappe-folder/apps/frappe/frappe/installer.py”, line 117, in _new_site
install_app(app, verbose=verbose, set_as_patched=not source_sql, force=False)
File “/home/frappe/frappe-folder/apps/frappe/frappe/installer.py”, line 318, in install_app
sync_for(name, force=force, reset_permissions=True)
File “/home/frappe/frappe-folder/apps/frappe/frappe/model/sync.py”, line 112, in sync_for
import_file_by_path(
File “/home/frappe/frappe-folder/apps/frappe/frappe/modules/import_file.py”, line 146, in import_file_by_path
import_doc(
File “/home/frappe/frappe-folder/apps/frappe/frappe/modules/import_file.py”, line 239, in import_doc
doc.insert()
File “/home/frappe/frappe-folder/apps/frappe/frappe/model/document.py”, line 334, in insert
self.run_post_save_methods()
File “/home/frappe/frappe-folder/apps/frappe/frappe/model/document.py”, line 1177, in run_post_save_methods
self.run_method(“on_update”)
File “/home/frappe/frappe-folder/apps/frappe/frappe/model/document.py”, line 1011, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-folder/apps/frappe/frappe/model/document.py”, line 1371, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-folder/apps/frappe/frappe/model/document.py”, line 1353, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-folder/apps/frappe/frappe/model/document.py”, line 1008, in fn
return method_object(*args, **kwargs)
File “/home/frappe/frappe-folder/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 549, in on_update
self.run_module_method(“on_doctype_update”)
File “/home/frappe/frappe-folder/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 647, in run_module_method
module = load_doctype_module(self.name, self.module)
File “/home/frappe/frappe-folder/apps/frappe/frappe/modules/utils.py”, line 286, in load_doctype_module
raise ImportError(msg) from e
ImportError: Module import failed for Dropbox Settings, the DocType you’re trying to open might be deleted.
Error: No module named ‘pkg_resources’

Try version 15 hotfix branch

Even without that bench PR you linked, it should work.

Can you try using both version-15-hotfix of frappe and erpnext?

Also, tomorrow’s release will have the fixes on the stable branch.

No, unfortunately it won’t work as-is because we rely on fixed versions for stability. Even once a stable release is available, it won’t automatically fix this for us. Applying it would require updating all of our clients’ instances to the newest Frappe and ERPNext version. That involves significant coordination with clients, testing of all our custom apps, and validation on our side.

Without the suggested PR all v15 versions that were published before tomorrow will be/are unusable. I doubt we’re the only ones facing this problem.

With the suggested PR, only Bench needs to be updated, which does not affect running instances.

I had to install dropbox>=12.0.0 to fix a setuptools >= 72 removed the pkg_resources module error. Frappe v15.95.0 pins dropbox==11.36.2, which imports pkg_resources in dropbox/session.py. On a fresh build, pip now pulls in setuptools 82+, which no longer ships pkg_resources, so upgrading Dropbox is required to make the stack install and run cleanly.