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

Running voila from command line in WSL (Windows 10) #773

Open
cdfredrickson opened this issue Dec 2, 2020 · 3 comments
Open

Running voila from command line in WSL (Windows 10) #773

cdfredrickson opened this issue Dec 2, 2020 · 3 comments

Comments

@cdfredrickson
Copy link

I am having a problem running Voila from the command line using Ubuntu 18.04 LTS with WSL on Windows 10. When running voila or voila NOTEBOOK_FILENAME, voila properly runs at localhost:8866. However, a new browser instance does not open and I get an error message saying my system cannot find the file specified ("file:///tmp/tmpxxxxxxxx.html") for the line Start "file:///tmp/tmpxxxxxxxx.html".

I have encountered a similar error with Jupyter Notebook in this environment. However, I was able to solve it by creating a jupyter_notebook_config.py file and setting c.NotebookApp.use_redirect_file = False, since there is a difference in file structures/paths between the runtime and the browser. Under this configuration, jupyter notebook properly runs and opens a new Chrome tab at localhost:8888. Is there an equivalent configuration for voila so I can run it from the command line and open a browser seamlessly without using --no-browser?

I've looked through all the available configurables for voila, but being a new user, it's hard to understand exactly what the options do. If this option exists, apologies!

Thank you!

@jtpio
Copy link
Member

jtpio commented Dec 21, 2020

Thanks @cdfredrickson.

It is very likely that the switch to the Jupyter Server ExtensionApp from #592 will make the configuration a bit easier and more streamlined.

@cdfredrickson
Copy link
Author

cdfredrickson commented Dec 23, 2020

Thank you @jtpio for the reply. Using the Jupyter Server ExtensionApp does work (replacing tree with voila in the Jupyter Server url). Under different circumstances, this would be fine. However, I have some reservations using Voilà this way.

Context: I was in a software development class and with a team, we created a dashboard with Jupyter Notebook and Voilà. We imagined our user would just be interacting with the dashboard and not our notebook.

When using the ExtensionApp, the user has to edit the url themselves, adding a step to actually run the dashboard. Additionally, the user could potentially revert back to tree and edit the dashboard notebook, functionality we do not want. Finally, it is another step to then click on the dashboard notebook to launch it with Voilà. We wanted to launch this dashboard as seamlessly as possible by using the command line (voila NOTEBOOK_FILENAME). I suspect this does not work with WSL for the same reason jupyter notebook did not work for me initially, but I could be wrong.

I would like to request a configuration option in Voilà similar to Jupyter:

Disable launching browser by redirect file
For versions of notebook > 5.7.2, a security feature measure was added that
prevented the authentication token used to launch the browser from being
visible. This feature makes it difficult for other users on a multi-user
system from running code in your Jupyter session as you.
However, some environments (like Windows Subsystem for Linux (WSL) and
Chromebooks), launching a browser using a redirect file can lead the browser
failing to load. This is because of the difference in file structures/paths
between the runtime and the browser.
Disabling this setting to False will disable this behavior, allowing the
browser to launch by using a URL and visible token (as before).
Default: True
c.NotebookApp.use_redirect_file = False

I understand if you don't want to add this option for security reasons and if this is the case, you can close this issue.

Again, thank you for your response and thank you for Voilà!

@pllim
Copy link
Contributor

pllim commented Jun 25, 2021

Hello. Not sure if my problem is the same problem, but I too am trying to run voila in WSL2 on Windows 10. I see that you have a --no-browser option now at https://voila.readthedocs.io/en/stable/deploy.html . It gives me a localhost URL. But when I paste that URL onto a browser on the Windows side, I get this error:

[Voila] Using /tmp to store connection files
[Voila] Storing connection files in /tmp/...
[Voila] Serving static files from .../.pyenv/versions/py38/lib/python3.8/site-packages/voila/static.
[Voila] Voilà is running at: ...
[Voila] WARNING | Notebook notebook.ipynb is not trusted
ERROR:tornado.application:Uncaught exception GET / (::1)
HTTPServerRequest(protocol='http', host='...', method='GET', uri='/', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
  File ".../.pyenv/versions/py38/lib/python3.8/site-packages/tornado/web.py", line 1704, in _execute
    result = await result
  File ".../.pyenv/versions/py38/lib/python3.8/site-packages/voila/handler.py", line 154, in get
    async for html_snippet, resources in self.exporter.generate_from_notebook_node(notebook, resources=resources, extra_context=extra_context):
  File ".../.pyenv/versions/py38/lib/python3.8/site-packages/voila/exporter.py", line 100, in generate_from_notebook_node
    async for output in self.template.generate_async(nb=nb_copy, resources=resources, **extra_context, static_url=self.static_url):
  File ".../.pyenv/versions/py38/lib/python3.8/site-packages/nbconvert/exporters/templateexporter.py", line 148, in template
    self._template_cached = self._load_template()
  File ".../.pyenv/versions/py38/lib/python3.8/site-packages/nbconvert/exporters/templateexporter.py", line 355, in _load_template
    return self.environment.get_template(template_file)
  File ".../.pyenv/versions/py38/lib/python3.8/site-packages/jinja2/environment.py", line 883, in get_template
    return self._load_template(name, self.make_globals(globals))
  File ".../.pyenv/versions/py38/lib/python3.8/site-packages/jinja2/environment.py", line 857, in _load_template
    template = self.loader.load(self, name, globals)
  File ".../.pyenv/versions/py38/lib/python3.8/site-packages/jinja2/loaders.py", line 429, in load
    raise TemplateNotFound(name)
jinja2.exceptions.TemplateNotFound: index.html.j2

When I use --no-browser with Jupyter notebook or lab, I get URL with token and it runs fine on Windows-side browser.

I'll be happy to move this to a new issue if this is indeed unrelated to the original post. Thanks!

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

No branches or pull requests

3 participants