Installation

The traffic library makes an intensive use of pandas DataFrames and of the shapely GIS library.

The library relies on requests for calls to REST APIs. paramiko implements the SSH protocol in Pure Python, giving access to SSH connection independently of the operating system.

Static visualisation tools are accessible with Matplotlib through the cartotools library, which leverages access to more projections and to data from OpenStreetMap. More dynamic visualisations in Jupyter Lab are accessible thanks to the altair and ipyleaflet libraries; other exports to various formats (including CesiumJS or Google Earth) are also available.

Installation

We recommend cloning the latest version from the repository before installing it.

git clone https://github.com/xoolive/traffic
cd traffic/
python setup.py install

If you are not comfortable with that option, you can always install the latest release:

pip install traffic

Warning

cartopy and shapely have strong dependencies to dynamic libraries which may not be available on your system by default. If possible, install Anaconda, then:

conda install cartopy shapely
# then _either_ with pip (stable version)
pip install traffic
# _or_ from sources (dev version)
python setup.py install

Troubleshooting

The following reported problems are not about the traffic library per se but related to limitations set by dependencies.

Python crashes when I try to reproduce plots in the documentation

(or, “My Jupyter kernel crashes…”)

There must be something wrong with your Cartopy and/or shapely installation. These libraries strongly depend on the geos and proj libraries. You must have shapely and Cartopy versions matching the correct versions of these libraries.

The problem is sometimes hard to understand, and you may end up fixing it without really knowing how.

If you don’t know how to install these dependencies, start with a fresh Anaconda distribution and install the following libraries the conda way:

conda install cartopy shapely

If it still does not work, try something along:

conda uninstall cartopy shapely
pip uninstall cartopy shapely
# be sure to remove all previous versions before installing again
conda install cartopy shapely

If it still does not work, try again with:

conda uninstall cartopy shapely
pip uninstall cartopy shapely
# this forces the recompilation of the packages
pip install --no-binary :all: cartopy shapely

Widgets do not display in Jupyter Lab or Jupyter Notebook

After executing a cell, you may see one of the following output:

A Jupyter Widget
# or
Error displaying widget
# or
HBox(children=(IntProgress(value=0, max=1), HTML(value='')))
# or
Map(basemap={'url': 'https://{s}.tile.openstreetmap.org/…

You will need to activate the widgets extensions:

  • with Jupyter Lab:

    jupyter labextension install @jupyter-widgets/jupyterlab-manager
    jupyter labextension install jupyter-leaflet
    jupyter labextension install keplergl-jupyter
    
  • with Jupyter Notebook:

    jupyter nbextension enable --py --sys-prefix widgetsnbextension
    jupyter nbextension enable --py --sys-prefix ipyleaflet
    jupyter nbextension enable --py --sys-prefix keplergl