Skip to content

Add dot to import in mbed/__main__.py to run as module #919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2019
Merged

Add dot to import in mbed/__main__.py to run as module #919

merged 1 commit into from
Sep 10, 2019

Conversation

JuhPuur
Copy link
Contributor

@JuhPuur JuhPuur commented Sep 5, 2019

Running mbed as a module with python -m (to ensure it's running from virtualenv) with python3 causes the following:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/juhpuur/mbed-cli/mbed/__main__.py", line 1, in <module>
    from mbed import main
ImportError: cannot import name 'main'

The fix is to add a dot to the import in __main__.py to tell python to search current package before rest of PYTHONPATH.

Copy link
Collaborator

@madchutney madchutney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I prefer absolute imports but this looks ok.

@OPpuolitaival
Copy link
Contributor

@JuhPuur did run mbed-os ci flow and this seems to work fine

@madchutney madchutney merged commit 6f035de into ARMmbed:master Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants