[Python] Python bokeh serve does not recognize local package located in the parent directory

Discussão em 'Python' iniciado por Stack, Março 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am hosting python script via:

    bokeh serve example.py

    and example.py loads local package 'local_module' located in the parent directory. When opening associated local host html (http://localhost:5006/example), the error pops up saying "ModuleNotFoundError: No module named 'local_module'".

    If placing the 'example.py' file in the the parent directory (where the package 'local_module' is located) then "bokeh serve" runs successfully and package is located when launching the html.

    Is there a way to configure Bokeh path variables that it would look into the local parent directory for the package (similarly like setting Python environment to look for local packages)?

    Upon looking through possible Bokeh Settings (https://docs.bokeh.org/en/latest/docs/reference/settings.html), it did not seem that any of the setting fields can be used to define the path that would be used to locate python packages.

    I am using PyCharm project which automatically extends sys.path to include project scope (in the venv of the project), thus 'example.py' runs normally and locates the package.

    I am running bokeh serve example.py from the PyCharm terminal window that has project's venv loaded.

    Continue reading...

Compartilhe esta Página