-
Notifications
You must be signed in to change notification settings - Fork 1
Ipython Notebooks
Ipython notebooks are now depricated, please use Jupyter notebooks
There a load of useful tutorials online Here
Basically, write your python script as if it were a notebook through a web browser. You can type in directly latex and HTML code to put pictures and equations in. It will convert itself into a python script or .tex file for you! It's really great to share stuff with people that aren't that familiar with python - simply upload your notebook to the nbviewer and share it!
Launching a local notebook is as simple as:
ipython notebook
you might want to add
c.IPKernelApp.pylab = 'inline'
to ~/.ipython/profile_default/ipython_notebook_config.py this will allow plots to show on the screen
I prefer to setup up to run remotely as its much faster!
*Please use the anaconda setup using setup command or if on your own machine, read the Anaconda file in this repository *
Offical info steps don't quite work on the NOCS systems but probably will on your own computer.
- open ipython through the terminal
ipython from IPython.lib import passwd
passwd()It will ask you for a password - the nocs system has trouble with symbols Just number and letters and it will work fine! It will output a key
- Copy this key
Ctrl+Z will suspend this process and take you back to the terminal
-
Create a profile for a computer e.g. theia
ipython profile create nbtheia cd ~/.ipython/profile_nbtheia
-
now edit the ipython_notebook_config.py add or uncomment the following lines:
c = get_config()
c.IPKernelApp.pylab = 'inline' # if you want plotting support always
c.NotebookApp.ip = '139.166.240.35' or 'theia.noc.soton.ac.uk
#Find from ifconfig command of hostname.noc.soton.ac.uk (must specify)
c.NotebookApp.open_browser = False # If true will launch Firefox through # X server (slow!) c.NotebookApp.password = u'[Paste your key here]'
c.NotebookApp.port = 9999
If that key is no longer in your clipboard type:
fg
to resume the ipython session and recopy it else just exit the session now. Create a directory in your home dir for your notebooks e.g.
mkdir notebooks
cd notebooks
-
now let's start the server:
screen -S nbserver ipython notebook --profile=nbtheia
This will start a screen session and launch the server
- On your own web browser go to
http://139.166.240.187:9999/ (The IP address and port number)
or
theia.noc.soton.ac.uk:9999
type in your password and start a new notebook.
Some of mine are readable to all so take a look for examples in ~hb1g13/Python/notebooks Now detach the screen so you can close the terminal window
Ctrl+A+D
- will detach the screen so you can exit while the process still runs*
If you want to reattach the screen
screen -r nbserver
I'm super lazy so I've set up aliases in my .cshrc nbtheia etc to start the server and then I've bookmarked the IP addresses.
Go to your folder with your notebook files to make a python script simply type
ipython nbconvert --to python notebook.ipynb
to make a latex document
ipython nbconvert --to latex notebook.ipynb
You will need to add ~hb1g13/bin/pandoc to your path Either copy it over or just add ~hb1g13/bin/ to your path in your .cshrc
setenv PATH "${PATH}:/noc/users/hb1g13/bin"
I store a lot of stuff in there so it is probably best to have your own ~/bin dir and copy over the file and simply add instead
setenv PATH "${PATH}:/noc/users/$USER/bin"
- Backends: Trouble with pyside/ matplotlib - you will need to edit:
~/.config/matplotlib/matplotlibrc
If you are using a more complex setup that might not be the right config file you can find out using:
import matplotlib
matplotlib.matplotlib_fname()
Normally I find switching away from Pyside fixes most things!
-
Kernal randomly dying with following error:
ipython notebook kernel died : cannot connect to X server localhost:20.0
FIX: %matplotlib inline
This is some crazy X forwarding error - I don't know why it's not being picked up in profile config file :s