Is it possible to host nbviewer locally?

2019-01-23 19:33发布

I want to bring nbviewer to my job. Because I am not able to share company data (place it on github), I will need to install nbviewer locally. There are instructions to set one up on Heroku but this will not work for me. Has anyone attempted this? Is it even worth the effort? Any other alternatives? Thanks.

Steps to get nbviewer running on your local machine:

Step1: Download nbviewer from github
Step2: Download nbconvert from github
Step3: Place nbconvert contents into the "nbconvert" folder inside nbviewer

Step4: Get required libraries
easy_install Flask==0.9
easy_install Flask-Markdown
easy_install requests
easy_install Pygments (comes with python xy)
easy_install Markdown==2.2.0
easy_install pylibmc==1.2.3
easy_install tornado
easy_install newrelic (failed to install optional c extension but think this is ok)
easy_install pyzmq (comes with python xy)

Step5: Edit gist.py
Comment out all these lines:

#from flask.ext.cache import Cache line 17   
#from lib.MemcachedMultipart import multipartmemecached line 20  
#cache = Cache(app, config=config) line 63  
#@cache.cached(5*hours) line 92  
#@cache.cached(5*hours) line 107  
#@cache.cached(5*hours) line 112  
#@cache.cached(5*hours) line 117  
#@cache.cached(5*hours) line 122  
#@cache.cached(5*hours) line 127  
#@cache.cached(1*minutes) line 133  
#@cache.memoize() line 177  
#@cache.memoize(10*minutes) line 201  

Step6: Run app.py
Step7: got to localhost:5000

How does one deal with authentication issues? (notebooks are in a repo that is password protected)
ERROR: Failed request: GET http svn/BizIntel/Trunk/notebook.ipynb: 401 Authorization Required

Answer: http username:password@svn/BizIntel/Trunk/notebook.ipynb

enjoy!

1条回答
混吃等死
2楼-- · 2019-01-23 19:56

Yes, nbviewer can be installed locally, that usually how we develop it. Yon can use heroku foreman if you want a setup close to heroku one with autorestart on your own machine.

If you want something easy, just clone nbviewer, install the dependencies in requirements.txt and run python app.py (maybe a submodule to git update. There might be a few environement variable to set like memcached, but you should be able to disable it if needed.

You can then open you browser to localhost:5000 and you should have your own version of nbviewer running locally.

It will not remove the necessity to have the ipynb file accessible through a local url for it to work, but if it's installed behind company firewall, that shouldn't be a problem.

Feel free to open issues on github if needed.

查看更多
登录 后发表回答