Bulding MAVProxy on Windows with custom module

I’ve developed a custom module “ers” for MAvproxy. It all works fine through the “dev” environment - running via “mavproxywinlan.bat”. However, when I do the windows installer build, and try to load my module I get the following:

"MAV> module load ers
Traceback (most recent call last):
File “mavproxy.py”, line 641, in import_package
File “PyInstaller\loader\pyimod03_importers.py”, line 540, in exec_module
** File “modules\mavproxy_ers_init_.py”, line 11, in **
ImportError: cannot import name ‘ersconsole’ from partially initialized module ‘MAVProxy.modules.mavproxy_ers’ (most likely due to a circular import) (C:\Program Files (x86)\MAVProxy\MAVProxy\modules\mavproxy_ers_init_.pyc)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “mavproxy.py”, line 487, in load_module
File “mavproxy.py”, line 644, in import_package
File “PyInstaller\loader\pyimod03_importers.py”, line 540, in exec_module
File “modules\mavproxy_ers_init_.py”, line 11, in
ImportError: cannot import name ‘ersconsole’ from partially initialized module ‘MAVProxy.modules.mavproxy_ers’ (most likely due to a circular import) (C:\Program Files (x86)\MAVProxy\MAVProxy\modules\mavproxy_ers_init_.pyc)

Traceback (most recent call last):
File “mavproxy.py”, line 641, in import_package
ModuleNotFoundError: No module named ‘ers’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “mavproxy.py”, line 487, in load_module
File “mavproxy.py”, line 644, in import_package
ModuleNotFoundError: No module named ‘ers’

Failed to load module: No module named ‘ers’."

Here’s line 11 of mavproxy_ers.py

“from MAVProxy.modules.lib import ersconsole”

ersconsole.py is in /modules/lib

Is there something in a makefile or equivalent I’m missing?

@stephendade ?

I’d have to take a look at your code to give a definitive answer.

Generally, if the dev environment works, but not the Windows installer - usually means the installer failed pick up and include all the files/dependencies from your module. In particular if you depend on data files (images, icons, etc) or and external pip packages.

If you take a look at ./windows/mavproxy.spec, you’ll see the manually included data files and packages.

In your case though, the **circular import** error message is interesting - I’m suprised that didn’t come up in the dev environment. It may be a module naming issue - take a look at python - ImportError: cannot import name '...' from partially initialized module '...' (most likely due to a circular import) - Stack Overflow

Turned out to be a PEBKAC - I’d tried to move the module into its own directory, so created a “module_ers” directory. That failed, so I moved everything back out, but forgot to delete the directory so there were two “module_ers” things, and a init.py sitting in the module_ers directory.

Deleting that directory resulted in happiness.

That article prompted me to take a closer look at the structure and that’s when I caught it - THANKS!!