Note: libBGPStream must be installed prior to installing PyBGPStream
The simplest and recommended way to install PyBGPStream is from
PyPI using pip
:
$ pip install pybgpstream
That's it!
sudo apt-get install python-pybgpstream
For Python 3:
sudo apt-get install python3-pybgpstream
If you prefer to install PyBGPStream from source, simply run the following commands:
$ mkdir ~/src
$ cd ~/src/
$ curl -LO https://github.com/CAIDA/pybgpstream/releases/download/v2.0.2/pybgpstream-2.0.2.tar.gz
$ tar zxf pybgpstream-2.0.2.tar.gz
$ cd pybgpstream-2.0.2
$ python setup.py build_ext
$ sudo python setup.py install
Use python setup.py install --user
to install the
library in your home directory.
To check if pybgpstream is installed correctly run the tutorial print script:
$ curl https://raw.githubusercontent.com/CAIDA/pybgpstream/master/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'}
...
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