Skip to content
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

[BUG] python global injection leads to error on first script run on any page #401

Open
um1642 opened this issue Feb 14, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@um1642
Copy link

um1642 commented Feb 14, 2025

Describe the bug
When any Global Injection is defined in the Settings:

Running for the first time a run-python block in edit:preview or view mode:

  • there will be an error message (see below)
  • the code is executed with its correct result

Running any script after the first on the same note:

  • there is no more error message
  • the code is executed with its correct result

Error message in edit:view mode:

ImportError: No module named __main__

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 191, in _run_module_as_main
  File "<frozen runpy>", line 243, in _get_main_module_details
runpy._Error: can't find '__main__' module in 'C:\\Users\\user\\AppData\\Local\\Obsidian'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 194, in _run_module_as_main
SystemExit: C:\Python313\python.exe: can't find '__main__' module in 'C:\\Users\\user\\AppData\\Local\\Obsidian'

Error message in view mode:

SystemExit: C:\Python313\python.exe: can't find '__main__' module in 'C:\\Users\\user\\AppData\\Local\\Obsidian'

Software Version
OS: WIN11
Plugin Version: 2.0.0
Obsidian Version: 1.8.4

To Reproduce
Steps to reproduce the behavior:

  1. settings: persistent output: disabled, notebook mode: enabled
  2. settings: global injection:
    def dummy(): pass
  3. create an empty run-python bloc
  4. run it once -> see there is an error
  5. run it again -> see there is no more error

Expected behavior
there should be no error from at the first run

Screenshots
has no additional interest here

Additional context
none

@um1642 um1642 added the bug Something isn't working label Feb 14, 2025
@um1642
Copy link
Author

um1642 commented Feb 14, 2025

I said "run-python" bloc but it is also applicable for "python" bloc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant