1.3 Python setup
Throughout this tutorial, we’ll use Python. Specifically, we’ll use the package called Networkx. Networkx is useful and handy in terms of calculating properties of networks but isn’t always helpful for creating visualizations. To visualize networks, we’ll use Gephi.
Don’t worry if you don’t know anything about any of them. I’ll walk you through them now.
You can refer to this video to get a better understanding of why and how to use Anaconda.
To install Anaconda, go here and choose the version for you. For MacOs, choose the “Command Line Installer” only if you want to feel like a hacker.
18.104.22.168.1 If you don’t have enough storage
The full Anaconda takes more than 3G of your storage. If storage is a problem for you, you can install the lightweight version of it: Miniconda. You can look here to know more about the differences between the two. To put it simply, Anaconda comes with a long list of packages pre-installed, so you don’t have to install each of them separately by yourself. However, you’ll have to do so for Miniconda.
If you decide to use Miniconda for whatever reason, after installing it, open your
Terminal and do the following (If you are using Anaconda, you don’t need to). I am assuming that you are using a Mac:
conda --version # To check whether the installation was successful
If the installation was successful, then do the following:
# To download jupyter notebook, and jupyterlab: conda install -c conda-forge vega notebook jupyterlab # To download packages we'll need to use later: conda install numpy scipy networkx jupyter conda install pandas matplotlib seaborn bokeh scikit-learn
Even if you are using Anaconda, sometimes you might need to use some packages that are not already installed and you’ll need to install them by yourself. Simply run
conda install your-package-name. Most of the packages could be installed that way. Of course, you can still use
pip to download packages even if you are using Anaconda (or Miniconda). Run
22.214.171.124.2 If you don’t want to use either Anaconda or Miniconda
If your computer is running on a MacOS or a Linux system, then you can also use
pip to install python packages. First, you need to download Python here. Then, go to
Terminal and run the following code, which came from Professor YY’s tutorial.
pip3 install numpy scipy networkx jupyter jupyterlab ipython pip3 install pandas matplotlib seaborn bokeh scikit-learn
126.96.36.199 Jupyter Notebook
As the above two videos showed, to open jupyter notebook, you simply need to type
jupyter notebook in your
Terminal. It’s quite straightforward. One trick you might need to know is that you can first go to the directory of your file, for example,
cd Desktop/netsci and then run
jupyter notebook. This way, you can use jupyter notebook right in the folder you want. This might save some of your time.
188.8.131.52.1 Jupyter Notebook On the cloud
If you don’t want to use jupyter notebook on your computer, you can try Google’s Colab which allows you to run python codes on the cloud.
184.108.40.206 Most importantly, Python
I haven’t talked about Python, the most important tool we are going to use in this tutorial yet. I don’t recommend you to attend a detailed python course now, since it’s not necessary for this tutorial.
To get started with Python, read these two instructions:
Do expect one, two, or even more days on these if you don’t have any experience using Python before. Make sure that you understand most of the codes in the above two instructions before you begin. Open your
jupyter notebook and try to implement the codes in the above two tutorials now.