Skip to content

ModuleNotFoundError when running model-checker with example on macOS #73

@benbrastmckie

Description

@benbrastmckie

Bug Description

When running model-checker with no arguments and selecting to test an example, the program crashes with a ModuleNotFoundError.

Environment

  • OS: macOS (Darwin 24.6.0)
  • Python: 3.13
  • model-checker version: 1.1.0
  • Installation method: pip3 install model-checker

Steps to Reproduce

  1. Install model-checker: pip3 install model-checker
  2. Run: model-checker (with no arguments)
  3. When prompted "Would you like to test an example in your project? (y/n):", enter: y

Expected Behavior

The example should run successfully or provide clear guidance on proper usage.

Actual Behavior

The program crashes with the following error:

Running example: /Users/nicky/Documents/project_test/examples.py
Traceback (most recent call last):
  File "/Users/nicky/Library/Python/3.13/lib/python/site-packages/model_checker/builder/loader.py", line 556, in _load_as_package_module
    module = importlib.import_module(full_module_name)
  File "/usr/local/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'project_test'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/nicky/Library/Python/3.13/bin/model-checker", line 7, in <module>
    sys.exit(run())
             ~~~^^
  File "/Users/nicky/Library/Python/3.13/lib/python/site-packages/model_checker/__main__.py", line 266, in run
    main()
    ~~~~^^
  File "/Users/nicky/Library/Python/3.13/lib/python/site-packages/model_checker/__main__.py", line 254, in main
    module = BuildModule(module_flags)
  File "/Users/nicky/Library/Python/3.13/lib/python/site-packages/model_checker/builder/module.py", line 64, in __init__
    self._load_module()
    ~~~~~~~~~~~~~~~~~^^
  File "/Users/nicky/Library/Python/3.13/lib/python/site-packages/model_checker/builder/module.py", line 90, in _load_module
    self.module = self.loader.load_module()
                  ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/nicky/Library/Python/3.13/lib/python/site-packages/model_checker/builder/loader.py", line 270, in load_module
    return self._load_as_package_module()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/nicky/Library/Python/3.13/lib/python/site-packages/model_checker/builder/loader.py", line 568, in _load_as_package_module
    raise ImportError(
    ...<2 lines>...
    )
ImportError: Failed to import project_test.examples from package project_test. Make sure all relative imports are correct. Original error: No module named 'project_test'

Error running example: Command '['model-checker', '/Users/nicky/Documents/project_test/examples.py']' returned non-zero exit status 1.
You can run it manually with: model-checker /Users/nicky/Documents/project_test/examples.py

Additional Context

The issue appears to be that the example tries to import from a non-existent project_test module when it should either:

  1. Create the necessary project structure first
  2. Use a standalone example that doesn't require a package structure
  3. Provide clearer instructions on the expected project setup

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions