Extension stopped working in Slicer 5

My extension MRUSLandmarking stopped working when Slicer 5 was introduced.

It works when I add it ‘locally’ through Extension Wizard → Select Extension, however, when it is installed through the Extension Manager it cannot be loaded.

The error comes from an import statement from the beginning of the main file, where I import a .py file where I have additional code:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Applications/Slicer-stable.app/Contents/lib/Python/lib/python3.9/imp.py", line 169, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 613, in _exec
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Applications/Slicer-stable.app/Contents/Extensions-30893/MRUSLandmarking/lib/Slicer-5.0/qt-scripted-modules/MRUSLandmarking.py", line 12, in <module>
    import Resources.utils
ModuleNotFoundError: No module named 'Resources.utils'

I’m confused why this error only happens through the extension manager.

I couldn’t find any guidelines on how to correctly do those imports in Slicer extensions, and I came up with the current way through trial and error.

What is the correct way of doing this?

Provably you have put some Python scripts into the resources folder but you have forgot to add it to the install package. You need to list files that you want to be installed on the user’s computer in the CMakeLists.txt file.

A proper fix is not simply add this file to the resources folder, because that file is intended only for resource files (images, data files, etc), not code. See how to add more Python files to your module here.