Note: libBGPStream must be installed prior to installing PyBGPStream

Installing from PyPI

The simplest and recommended way to install PyBGPStream is from PyPI using pip:

$ pip install pybgpstream

Thats it!

Installing from source

If you prefer to install PyBGPStream from source, simply run the following commands:

$ mkdir ~/src
$ cd ~/src/
$ curl -O http://bgpstream.caida.org/bundles/caidabgpstreamwebhomepage/dists/pybgpstream-1.1.0.tar.gz
$ tar zxf pybgpstream-1.1.0.tar.gz
$ cd pybgpstream-1.1.0
$ python setup.py build_ext
$ sudo python setup.py install

Use python setup.py install --user to install the library in your home directory.

Testing the installation

To check if pybgpstream is installed correctly run the tutorial print script:

$ curl https://raw.githubusercontent.com/CAIDA/bgpstream/v1.1.0/pybgpstream/examples/tutorial_print.py | python
valid ris.rrc06 1427846570
    W 202.249.2.185 25152 W {'prefix': '144.104.37.0/24'}
valid ris.rrc06 1427846573
    A 2001:200:0:fe00::6249:0 25152 A {'next-hop': '2001:200:0:fe00::9c1:0', 'prefix': '2a00:bdc0:e004::/48', 'as-path': '25152 2497 6939 47541 28709'}
...

Troubleshooting

The BGPStream C library must be installed prior to installing pybgpstream. If you see an error like the following during installation, then you may not have libBGPStream installed .

In file included from src/_pybgpstream_module.c:27:
    src/_pybgpstream_bgprecord.h:29:10: fatal error: 'bgpstream.h' file not found

If you have installed libBGPStream to a non-standard location (e.g., /path/to/libbgpstream), then you will need to provide more information to pip as follows:

pip install \
    --global-option build_ext \
    --global-option '--include-dir=/path/to/libbgpstream/include' \
    --global-option '--library-dir=/path/to/libbgpstream/lib' \
    pybgpstream

or, if you are installing from source

In this case you may also have to tell Python where to find libBGPStream at run time like so:

LD_LIBRARY_PATH=/path/to/libbgpstream/lib python my_bgpstream_app.py