IPython is a powerful, interactive shell for Python, considered by many to be a replacement for the standard Python shell. It's most likely in your repositories under ipython
(or ipython3
or ipython2
depending on which Python version is native to your distro). There's tons of information available and it's highly customizable -- even coming with support languages other than Python.
%%bash
echo "Hello from $BASH"
But what I'm really going to evangelize today is the Notebook portion of it. You'll probably have to install the notebook separately -- typically listed under ipython-notebook
in repositories. In fact, I'm blogging from it right now.
What is a Notebook
A Notebook is a portable IPython session that runs in your browser. When you run ipython notebook
it starts a local server and it'll probably attempt to launch a browser, too. If not, open one up and navigate to 127.0.0.1:8888
and you'll see the IPython Notebook dashboard, which'll list all the notebooks in the directory it was launched in and allow you create new ones, run present ones and even delete them.
In many ways, a Notebook is just like using IPython on the commandline. Code in run cells is available to cells below it. You can even use IPython's magics in them.
Sharing Notebooks
IPython stores Notebooks in ipynb
files -- JSON by any other name -- in the directory that the Notebook server was launched in. From there, you can store them on Github, send them to friends, host a Notebook Viewer server yourself,
Also, you can convert the Notebooks to other formats: markdown, HTML, Latex, PDF, reStructured Text, javascript slides, and actual Python files. To do so, you simply run: ipython nbconvert --to {format} [FILE]
. However, you may have to install the pacdoc
package to do so (I did). I'll be covering converting them to HTML and using them with Google's Blogger platform
Blogging with IPython Notebooks
The first step is to, of course, actually produce an IPython Notebook. You already know how, so just do it.
After you have your notebook, pandoc is installed, and you're sitting with a terminal open, you'll want to run ipython nbconvert --to html mynb.ipynb
. This'll generate a full HTML page complete with CSS and the necessary Javascript to display mathematical equations. You'll want to extract this CSS and Javascript and place it into your Blogger template.
Modifying Blogger Templates
To do this, I actually didn't use vim, I used the text editor that came with Mint. Simply paste this CSS into the template by going in through Template > Customize > Advanced > Add CSS
. And then the Javascript by going in through Template > Edit HTML
and pasting it in somewhere in the <head>
tag.
Translating Notebooks to HTML
To get just the body of the Notebook in HTML form, use ipython nbconvert --to html --template basic mynb.ipynb
. Then simply copy the generated HTML into the HTML portion of a new Blogger post. If you use Linux, there's actually a fairly simple way of doing this on the command line: xclip. xclip -selection c mynb.html
. Alternatively, if you don't care if the actual HTML file is generated you can just run ipython nbconvert --to html --template basic --stdout mypy.ipynb | xclip -selection c
. Then simply CRTL-V in the HTML editor for blogger and click Publish.
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeletepython training in bangalore|
Great job dude.Very clear descriptions and comparisons.
ReplyDeletelenovo mobile service center near me
Articles are inspiring,Great Information's are shared here.I look forward to your writing
ReplyDeletepython training in chennai | python training in annanagar | python training in omr | python training in porur | python training in tambaram | python training in velachery
Thank you so much for the great and very beneficial stuff that you have shared with the world.
ReplyDeletejava training in chennai
java training in tambaram
aws training in chennai
aws training in tambaram
python training in chennai
python training in tambaram
selenium training in chennai
selenium training in tambaram
Thanks a lot very much for the high your blog post quality and results-oriented help. I won’t think twice to endorse to anybody who wants and needs support about this area.
ReplyDeleteangular js training in chennai
angular js training in velachery
full stack training in chennai
full stack training in velachery
php training in chennai
php training in velachery
photoshop training in chennai
photoshop training in velachery
Really very happy to say, your post is very interesting to read. I never stop myself to say something about it. You’re doing a great job. Keep it up...
ReplyDeleteangular js training in chennai
angular js training in omr
full stack training in chennai
full stack training in omr
php training in chennai
php training in omr
photoshop training in chennai
photoshop training in omr
Thank you for the informative post. It was thoroughly helpful to me. Keep posting more such articles and enlighten us.
ReplyDeletedata science training in chennai
data science training in annanagar
android training in chennai
android training in annanagar
devops training in chennai
devops training in annanagar
artificial intelligence training in chennai
artificial intelligence training in annanagar