'Plot a local image using bokeh image_url by running python with the -m option

I have to run a bokeh script as a module using the -m option from the top directory, because it needs to import some other portable module under the same directory

python -m bokeh_module.bokeh_sub_module

The directory tree is shown below. By running the above command, it doesn't show the image no matter where the png file is placed, is there a way to resolved the issue? Thank you for any help.

.
├── other_module
│   ├── __init__.py
│   └── other_sub_module.py
├── bokeh_module
│   ├── __init__.py
│   ├── image.png # not showing
│   └── bokeh_sub_module.py
└── image.png # not showing either

bokeh_sub_module.py

from other_module import other_sub_module
from bokeh.plotting import figure, show

# do something with other_sub_module
p = figure(match_aspect=True)
p.image_url( ['image.png'], 0, 0, 1, 1 ) # not showing
p.image_url( ['./bokeh_module/image.png'], 0, 0, 1, 1 ) # not showing either
show(p)

By the way, if I run python bokeh_sub_module.py from the bokeh_module directory, the image.png inside the same directory can be found with no problems.



Solution 1:[1]

image_url requires URLs, and neither of your calls to image_url use URLs.

Try to use absolute URLs and add file:// in front of them.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eugene Pakhomov