In [ ]:
!sudo chown jupyter-sheng_wei:docker /var/run/docker.sock
!docker run -p 8080:8080 jupyter/nbviewer
In [ ]:
!sudo -HE pip install nbviewer
!sudo -E python -m nbviewer --help
In [ ]:
!echo JUPYTERHUB_SERVICE_PREFIX=$JUPYTERHUB_SERVICE_PREFIX
JUPYTERHUB_SERVICE_PREFIX=/user/sheng_wei/
In [ ]:
!sudo bash -c 'echo JUPYTERHUB_SERVICE_PREFIX=$JUPYTERHUB_SERVICE_PREFIX'
JUPYTERHUB_SERVICE_PREFIX=
In [ ]:
!ls -lahd /home/jupyter-sheng_wei
!ls -lahd /home/jupyter-sheng_wei/hexo && echo
!sudo python -m nbviewer --base-url=/ --localfiles=/home/jupyter-sheng_wei/hexo --no-cache --logging=debug
drwxr-x--- 24 jupyter-sheng_wei jupyterhub-users 4.0K Oct 20 21:06 /home/jupyter-sheng_wei
drwxr-xr-x 13 jupyter-sheng_wei jupyterhub-users 4.0K Oct 20 18:58 /home/jupyter-sheng_wei/hexo

[I 191020 22:23:36 app:124] Not indexing notebooks
[I 191020 22:23:36 app:128] Not using cache
fatal: not a git repository (or any of the parent directories): .git
[E 191020 22:23:36 app:166] Failed to get git info: Command '['git', 'log', '-1', '--format=%H\n%s\n%cD']' returned non-zero exit status 128.
[D 191020 22:23:36 selector_events:65] Using selector: EpollSelector
[W 191020 22:23:36 app:250] Serving local notebooks in /home/jupyter-sheng_wei/hexo, this can be a security risk
[I 191020 22:23:36 app:330] Listening on 0.0.0.0:5000, path /
[E 191020 22:23:40 web:1670] Uncaught exception GET /faq (110.3.247.172)
    HTTPServerRequest(protocol='http', host='jhub.name:5000', method='GET', uri='/faq', version='HTTP/1.1', remote_ip='110.3.247.172')
    Traceback (most recent call last):
      File "/opt/tljh/user/lib/python3.6/site-packages/tornado/web.py", line 1590, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/opt/tljh/user/lib/python3.6/site-packages/nbviewer/handlers.py", line 44, in get
        self.finish(self.render_template('faq.md'))
      File "/opt/tljh/user/lib/python3.6/site-packages/nbviewer/providers/base.py", line 249, in render_template
        return template.render(**ns)
      File "/opt/tljh/user/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
        return original_render(self, *args, **kwargs)
      File "/opt/tljh/user/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
        return self.environment.handle_exception(exc_info, True)
      File "/opt/tljh/user/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
        reraise(exc_type, exc_value, tb)
      File "/opt/tljh/user/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
        raise value.with_traceback(tb)
      File "/opt/tljh/user/lib/python3.6/site-packages/nbviewer/templates/faq.md", line 1, in top-level template code
        {% extends "layout.html" %}
      File "/opt/tljh/user/lib/python3.6/site-packages/nbviewer/templates/layout.html", line 118, in top-level template code
        {% block container %}<div class="container container-main">
      File "/opt/tljh/user/lib/python3.6/site-packages/nbviewer/templates/layout.html", line 119, in block "container"
        {% block body %}{% endblock %}
      File "/opt/tljh/user/lib/python3.6/site-packages/nbviewer/templates/faq.md", line 5, in block "body"
        {% filter markdown(extensions=['headerid(level=3)','toc'], extension_configs= {'toc' : [('anchorlink', True)]}) %}
      File "/opt/tljh/user/lib/python3.6/site-packages/markdown/core.py", line 390, in markdown
        md = Markdown(**kwargs)
      File "/opt/tljh/user/lib/python3.6/site-packages/markdown/core.py", line 100, in __init__
        configs=kwargs.get('extension_configs', {}))
      File "/opt/tljh/user/lib/python3.6/site-packages/markdown/core.py", line 126, in registerExtensions
        ext = self.build_extension(ext, configs.get(ext, {}))
      File "/opt/tljh/user/lib/python3.6/site-packages/markdown/core.py", line 166, in build_extension
        module = importlib.import_module(ext_name)
      File "/opt/tljh/user/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'headerid(level=3)'
[E 191020 22:23:40 log:52] {
      "Host": "jhub.name:5000",
      "Connection": "keep-alive",
      "Pragma": "no-cache",
      "Cache-Control": "no-cache",
      "Upgrade-Insecure-Requests": "1",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
      "Referer": "http://jhub.name:5000/localfile/source/notebooks/Try-Plotly-Dash.ipynb",
      "Accept-Encoding": "gzip, deflate",
      "Accept-Language": "ja,en-US;q=0.9,en;q=0.8,zh-CN;q=0.7,zh;q=0.6",
      "Cookie": "_xsrf=2|a81713c9|4a10b65ad1b4264e0b304a10743350a3|1570958079; G_ENABLED_IDPS=google; mjx.latest=2.7.6"
    }
[E 191020 22:23:40 log:53] 500 GET /faq (110.3.247.172) 143.11ms referer="http://jhub.name:5000/localfile/source/notebooks/Try-Plotly-Dash.ipynb" user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"
[D 191020 22:23:40 log:53] 200 GET /static/build/styles.css?v=20d08094b44c75ee15fd5045973d36e5 (110.3.247.172) 7.74ms
[D 191020 22:23:40 log:53] 200 GET /static/components/requirejs/require.js?v=6da8be361b9ee26c5e721e76c6d4afce (110.3.247.172) 4.48ms
[D 191020 22:23:40 log:53] 200 GET /static/components/moment/min/moment.min.js?v=89f87298ad94aa1e6b92f42eb66da043 (110.3.247.172) 2.21ms
[D 191020 22:23:40 log:53] 200 GET /static/components/bootstrap/js/bootstrap.min.js?v=5869c96cc8f19086aee625d670d741f9 (110.3.247.172) 2.07ms
[D 191020 22:23:40 log:53] 200 GET /static/img/nav_logo.svg?v=479cefe8d932fb14a67b93911b97d70f (110.3.247.172) 0.97ms
[D 191020 22:23:40 log:53] 200 GET /static/components/jquery/dist/jquery.min.js?v=e071abda8fe61194711cfc2ab99fe104 (110.3.247.172) 13.51ms
[D 191020 22:23:40 log:53] 200 GET /static/components/headroom.js/dist/headroom.min.js?v=b0a311ea668f8e768ea375f4a7abb81c (110.3.247.172) 1.11ms
[D 191020 22:23:41 log:53] 200 GET /static/components/headroom.js/dist/jQuery.headroom.min.js?v=f3a1bae118315d0c234afc74dc6aab71 (110.3.247.172) 1.01ms
[D 191020 22:23:52 log:53] 200 GET /static/ico/ipynb_icon_16x16.png (110.3.247.172) 0.77ms
^C
Traceback (most recent call last):
  File "/opt/tljh/user/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/tljh/user/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/tljh/user/lib/python3.6/site-packages/nbviewer/__main__.py", line 2, in <module>
    main()
  File "/opt/tljh/user/lib/python3.6/site-packages/nbviewer/app.py", line 332, in main
    ioloop.IOLoop.current().start()
  File "/opt/tljh/user/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 132, in start
    self.asyncio_loop.run_forever()
  File "/opt/tljh/user/lib/python3.6/asyncio/base_events.py", line 427, in run_forever
    self._run_once()
  File "/opt/tljh/user/lib/python3.6/asyncio/base_events.py", line 1404, in _run_once
    event_list = self._selector.select(timeout)
  File "/opt/tljh/user/lib/python3.6/selectors.py", line 445, in select
    fd_event_list = self._epoll.poll(timeout, max_ev)
KeyboardInterrupt

↑ Just skip the problem of ModuleNotFoundError: No module named 'headerid(level=3)' at /faq.

In [ ]:
!docker run -p 5000:5000 jupyter/nbviewer python -m nbviewer --base-url=/ --localfiles=/ --logging=debug

Try to Understand the Mechanism of NBViewer.

https://github.com/jupyter/nbviewer/blob/master/nbviewer/app.py

Comments

2019-10-20