Skip to content

No default module main found, if main.py contains import error #285

@velle

Description

@velle

If the main.py contains an import which raises ModuleNotFoundError, then the plugin concludes that it was the import of main itself that caused this exception, and then continues after printing a misleading warning: No default module `main` found. The expected and more helpful behavior would be a big obvious fail with ModuleNotFound :)

$ cat mkdocs.yml
site_name: My Test
plugins:
  - macros
$ cat main.py
import does_not_exist # raises ModuleNotFoundError
$ mkdocs serve
INFO    -  Building documentation...
INFO    -  [macros] - No default module `main` found
INFO    -  [macros] - Config variables: ['extra', 'config', 'environment', 'plugin', 'git', 'macros', 'filters', 'filters_builtin']
INFO    -  [macros] - Config macros: ['context', 'macros_info', 'now', 'fix_url']
INFO    -  [macros] - Config filters: ['pretty', 'relative_url']
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.05 seconds
INFO    -  [22:48:38] Serving on http://127.0.0.1:8000/
^CINFO    -  Shutting down...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions