Social and Technological Networks

University of Edinburgh. Autumn 2017. Level: Year4/5/Msc/CDT.

Setting up Networkx and IPython Notebooks in your DICE account

If you are using the dice machines in forrest hill, they already have everything installed. However, the networkx version there is not the latest. This should not be a problem in most cases, but if you want or need to install the latest, instructions are below.

Anyone using other DICE machines, or logging in remotely, needs to setup as follows.

In examples shown in class, I am using python 2. Which is mostly similar to python 3, and will generally work without change on python 3, but sometimes may need syntax correction.

If you would like to use python 2, or want examples from class to run without change, use the following guide. If you are not sure, you should use python 2.

Setting up Python 2

Python 2.7 is already installed on DICE, but needs networkx, ipython, and jupyter-notebook for it. To install that, follow the steps below. Note that this will install things to your user space. You will not need administrator access or any special permission.

Open a terminal.

  1. We will install an installer program called pip. Execute from command line:

    wget -O get-pip.py  "https://bootstrap.pypa.io/get-pip.py"
    

    This will download the file.

  2. Run the file using python:

    python2.7 get-pip.py --user        
    

    This will install pip in your user space

  3. Now install the packages we need

    python2.7 -m pip install --user networkx 
    
    python2.7 -m pip install --user matplotlib          
    python2.7 -m pip install --user ipython 
    
    python2.7 -m pip install --user jupyter
    
    
  4. Check that they worked:

    ~/.local/bin/ipython

    Should show a version of python > 2.7. Exit it by ctrl+d.

  5. ~/.local/bin/jupyter-notebook

    Should start notebook. Note that ipython notebook has been changed to jupyter-notebook now. Exit it by ctrl+c.

  6. To avoid having to type the entire path everytime, add the following two lines to the end of files .bash_login and .bashrc located in your home folder. (If .bash_login and .bashrc do not exit, create them and add the lines)

    alias python=python2.7  
    alias ipython="~/.local/bin/ipython"
    

    Logout and log back in again. This will ensure that you are using 2.7 and the corresponding ipython. If you need to go back to the default python, remove these lines from the files and logout.

Setting up python 3

Only for those who want to use Python 3.

Should be similar. Except that pip is already installed and you can run it by pip3. This also simplifies package installs, for example

    pip3 install --user networkx