For years, I have been using NetworkX and hadn’t found any good substitute which has fast execution as CPP with rapid development as python. SNAP is a powerful tool which is aimed to be built this direction. For researches in network science, it provides tools to do general purpose and high performance system for analysis and manipulation of large networks.

Installing SNAP-python in Linux, Mac OS X and Windows is given here in this website.

Sometimes when you are working on a library that is still under development it is better to use virtualenv. A Virtual Environment, put simply, is an isolated working copy of Python which allows you to work on a specific project without worry of affecting other projects. For more details about virtualenv please take a look at this.

I faced certain problems with virtualenv and SNAP with Mac OS X 10.9.3. After reading few manuals on shared libraries, I could resolve this.

Here is the problem I faced:

>>> import snap
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

So I thought of writing a step by step blog to help users to install SNAP successfully with virtualenv.

To create a virtualenv directory :

virtualenv --python=$(which python) --distribute --no-site-packages snap/

Change your working directory to snap. Activate virtualenv and then install numpy, graphviz.

cd snap/
source bin/activate
pip install numpy
pip install graphviz

Install gnuplot with homebrew. Download and install python extension for gnuplot within the virtualenv snap. Now comes the last step of downloading and installing SNAP.py library. Download SNAP repository from the website and place it in the working directoy (snap/).

tar zxvf snap-1.0-2.2-macosx10.7.5-x64-py2.7.tar.gz
cd snap-1.0-2.2-macosx10.7.5-x64-py2.7
sudo python setup.py install

Execute the following lines in python or in ipython.

import snap

If you are getting the any errors related to PyThreadState_Get, then do the following.

install_name_tool -change bin/python /System/Library/Frameworks/Python.framework/Versions/2.7//lib/libpython2.7.dylib snap-1.0-2.2-macosx10.7.5-x64-py2.7/_snap.so

install_name_tool is used in Mac OS X to change dynamic shared library install names. Now try to run the snap example files. Voila! It should work.


Copyright © 2015 - Vijay Mahantesh SM - Powered by Octopress