免責聲明

Disclaimer (免責聲明)
繼續閱覽代表您接受以上的免責聲明.
To continue reading means you accept the above disclaimer.

2014年12月12日 星期五

try ipython #2, notebook

//=== http://www.randalolson.com/2012/05/12/a-short-demo-on-how-to-use-ipython-notebook-as-a-research-notebook/

IPython Notebook : seamless integration of text and code



//=== cell types

Markdown cell
Heading cell
Code cell
...


//===
[Q]  how to start ipython notebook from ipython console?

In [1]: notebook
UsageError: too few arguments
In [2]: !ipython notebook
--> dangerous??



[Q] how to stop ipython notebook?
[Q] how to close IPython Notebook properly?

after closing chrome browser,
the kernel is shutdown automatically,
but then
ctl+c does not work , nor other keys function,
the whole terminal console is frozen!
at last
--> kill  python process from Task Manager

//===
[Q] how to start ipython notebook with different profile ?
--> ipython notebook --profile=3h
xxx ipython --profile=3h notebook



[Q] how to view the plot result in noteboook?

http://nbviewer.ipython.org/github/ipython/ipython/blob/1.x/examples/notebooks/Part%203%20-%20Plotting%20with%20Matplotlib.ipynb

%matplotlib inline
--> use the inline backend, which will embed plots inside the Notebook:


//=== http://ipython.org/ipython-doc/1/interactive/nbconvert.html
The command-line syntax to run the nbconvert script is:

> ipython nbconvert --to FORMAT notebook.ipynb
This will convert the IPython document file notebook.ipynb into the output format given by the FORMAT string.

* default format is html
> ipython nbconvert ex1.ipynb
> ipython nbconvert --to markdown ex2.pynb --stdout


a configuration file, say mycfg.py,
"""...
c = get_config()
c.NbConvertApp.notebooks = ["ex1.ipynb", "ex2.ipynb"]
..."""
and using the command:

> ipython nbconvert --config mycfg.py



//=== [Q] how to host ipython on internet?
http://nbviewer.ipython.org/github/minrk/ipython/blob/master/examples/Notebook/Running%20the%20Notebook%20Server.ipynb

""" ...
 Most of the time, users run the notebook server on their local computer using IPython's command line interface.
...
You can also specify the port manually:
> ipython notebook --port 9999

Or start notebook server without opening a web browser.
> ipython notebook --no-browser

... """

//=== Securing the notebook server

* Setting a password
* Encrypt network traffic using SSL

In [1]:
from IPython.lib import passwd
password = passwd("my secret pswd")
password
Out[1]:
'sha1:6c2164fc2b22:ed55ecf07fc0f985ab46561483c0e888e8964ae6'

add the hashed passwd to myconfig.py:

"""
# Password to use for web authentication
c = get_config()
c.NotebookApp.password = u'sha1:6c2164fc2b22:ed55ecf07fc0f985ab46561483c0e888e8964ae6'
"""



//=== certificate/private key for  ssl/https
adding the following to  myconfig.py:

"""
# The full path to an SSL/TLS certificate file.
c.NotebookApp.certfile = u'/Users/bgranger/.ipython/profile_my_profile/mycert.crt'

# The full path to a private key file for usage with SSL/TLS.
c.NotebookApp.keyfile = u'/Users/bgranger/.ipython/profile_my_profile/mycert.key'
"""


//=== make notebook server public
by listening to arbitrary ip address ?

> ipython notebook --ip=* --no-browser

or add the following to  myconfig.py:

"""
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
"""



沒有留言:

張貼留言