Migration Error – ModuleNotFoundError: No module named 'pkg_resources'

Hello Everyone,

I’m facing an issue while upgrading my existing sites after switching to a newly built custom Docker image.

Setup Details

I created a custom image using:
https://github.com/castlecraft/custom_containers

My bench and sites are running in Docker Swarm based on:
https://github.com/castlecraft/custom_containers/blob/main/docs/docker-swarm.md

Note: I am not using the default frappe/erpnext image — I am using my own custom-built image.

Image Versions:

FRAPPE_VERSION=v15.69.1
PY_VERSION=3.11.6
NODEJS_VERSION=18.18.2

Installed Apps:

  • erpnext : v15.63.0

  • payments : version-15

  • hrms : v15.46.0

  • lms : v2.30.0

  • india-compliance : v15.18.1

Upgrade Scenario

  • Existing sites were running on Frappe v15.56.1

  • I built a new custom image with Frappe v15.69.1

  • After switching to the new image, I executed:

bench migrate

During migration, the process fails with the following error:

ModuleNotFoundError: No module named 'pkg_resources'

The traceback indicates the failure occurs while loading the Google Calendar DocType:

ImportError: Module import failed for Google Calendar, 
the DocType you're trying to open might be deleted.
Error: No module named 'pkg_resources'

From the traceback, it appears that googleapiclient is trying to import pkg_resources, but the module is not available in the environment.

Note

  • The Docker image builds successfully.

  • The issue only occurs during bench migrate.

  • I am using a fully custom image (not the official frappe/bench image).

Has anyone encountered a similar issue when upgrading minor v15 versions using a custom Docker image?

Any guidance to solve this issue would be greatly appreciated.

Thank you.

See Bench new-site throws Error: No module named ‘pkg_resources’ - #10 by marc_centura

Hello @marc_centura , i am using bench version v5.29.1.
Which releases the fix : Release v5.29.1 · frappe/bench · GitHub
but while migrating the existing site, i still encounter this issue. For me this appears for Google Calender instead of Dropbox

My latest custom image is using Frappe Bench v5.29.1, which includes a fix that limits setuptools to versions below 82 to prevent pkg_resources related failures during new site setup (specifically for the Dropbox integration).

However, despite using this Bench version, I am still encountering the same pkg_resources error when running:

bench --site <site-name> migrate

So even with the fix present in v5.29.1, the issue persists during site migration in my setup.