Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
615 views
in Technique[技术] by (71.8m points)

ipython notebook - Is it possible to host nbviewer locally?

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...