Open ahuang11 opened 1 year ago
Can you try an absolute path?
This did not work for me: pdf = pn.pane.PDF("~/Downloads/example.pdf", embed=False)
, whereas this did pdf = pn.pane.PDF(os.path.expanduser("~/Downloads/example.pdf"), embed=False)
MissingSchema: Invalid URL '~/Downloads/example.pdf': No scheme supplied. Perhaps you meant https://~/Downloads/example.pdf?
Traceback (most recent call last):
File "/home/shh/miniconda3/envs/holoviz/lib/python3.11/site-packages/bokeh/application/handlers/code_runner.py", line 229, in run
exec(self._code, module.__dict__)
File "/home/shh/Repos/holoviz/holoviews/tmp.py", line 8, in <module>
pdf.servable()
File "/home/shh/Repos/holoviz/panel/panel/viewable.py", line 392, in servable
self.server_doc(title=title, location=location) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/Repos/holoviz/panel/panel/viewable.py", line 1024, in server_doc
model = self.get_root(doc)
^^^^^^^^^^^^^^^^^^
File "/home/shh/Repos/holoviz/panel/panel/pane/base.py", line 425, in get_root
root_view, root = self._get_root_model(doc, comm, preprocess)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/Repos/holoviz/panel/panel/pane/base.py", line 347, in _get_root_model
root = self._get_model(doc, comm=comm)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/Repos/holoviz/panel/panel/pane/base.py", line 500, in _get_model
model = self._bokeh_model(**self._get_properties(doc))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/Repos/holoviz/panel/panel/reactive.py", line 556, in _get_properties
properties = self._process_param_change(params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/Repos/holoviz/panel/panel/pane/base.py", line 523, in _process_param_change
params.update(self._transform_object(params.pop('object')))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/Repos/holoviz/panel/panel/pane/image.py", line 486, in _transform_object
data = self._data(obj)
^^^^^^^^^^^^^^^
File "/home/shh/Repos/holoviz/panel/panel/pane/image.py", line 115, in _data
r = requests.request(url=obj, method='GET')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/miniconda3/envs/holoviz/lib/python3.11/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/miniconda3/envs/holoviz/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
prep = self.prepare_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/miniconda3/envs/holoviz/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
p.prepare(
File "/home/shh/miniconda3/envs/holoviz/lib/python3.11/site-packages/requests/models.py", line 368, in prepare
self.prepare_url(url, params)
File "/home/shh/miniconda3/envs/holoviz/lib/python3.11/site-packages/requests/models.py", line 439, in prepare_url
raise MissingSchema(
requests.exceptions.MissingSchema: Invalid URL '~/Downloads/example.pdf': No scheme supplied. Perhaps you meant https://~/Downloads/example.pdf?
Interesting, but it's a file uploaded through FileInput
so there's no absolute path.
contents = self._exit_stack.enter_context(
BytesIO(contents)
)
renderer = partial(PDF, embed=True)
Without embed, nothing shows:
With embed:
example.pdf