Skip to main content

Vowpal Wabbit Python package

Project description

PyPI Package Build Status Windows Build Status Coverage

Vowpal Wabbit is a fast machine learning library for online learning, and this is the python wrapper for the project.

Installing this package builds Vowpal Wabbit locally for explicit use within python, it will not create the command-line version of the tool (or affect any previously existing command-line installations). To install the command-line version see the main project page:

The version of the PyPI vowpalwabbit package corresponds to the tagged version of the code in the github repo that will be used during building and installation. If you need to make local changes to the code and rebuild the python binding be sure to pip uninstall vowpalwabbit then rebuild using the local repo installation instructions below.


From PyPI:

Linux/Mac OSX:

$ pip install vowpalwabbit


> pip install --global-option="--vcpkg-root=path\to\vcpkg" vowpalwabbit

From local repo (useful when making modifications):

# Dependencies
$ sudo apt install libboost-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev libboost-math-dev libboost-test-dev libboost-python-dev zlib1g-dev cmake

# Build and install package
$ python install


You can use the python wrapper directly like this:

>>> from vowpalwabbit import pyvw
>>> vw = pyvw.vw(quiet=True)
>>> ex = vw.example('1 | a b c')
>>> vw.learn(ex)
>>> vw.predict(ex)

Or you can use the included scikit-learn interface like this:

>>> import numpy as np
>>> from sklearn import datasets
>>> from sklearn.model_selection import train_test_split
>>> from vowpalwabbit.sklearn_vw import VWClassifier
>>> # generate some data
>>> X, y = datasets.make_hastie_10_2(n_samples=10000, random_state=1)
>>> X = X.astype(np.float32)
>>> # split train and test set
>>> X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=256)
>>> # build model
>>> model = VWClassifier()
>>>, y_train)
>>> # predict model
>>> y_pred = model.predict(X_test)
>>> # evaluate model
>>> model.score(X_train, y_train)
>>> model.score(X_test, y_test)


Some common causes of failure for installation are due to missing or mis-matched dependencies when Vowpal Wabbit builds. Make sure you have boost and boost-python installed on your system.

For Ubuntu/Debian/Mint

$ apt install libboost-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev libboost-math-dev libboost-test-dev libboost-python-dev zlib1g-dev cmake

For Mac OSX

$ brew install cmake
$ brew install boost
#If you want to build with python 2 support
brew install boost-python
#If you want to build with python 3 support
brew install boost-python3

For Windows

  1. Install vcpkg
  2. Run
> vcpkg --triplet x64-windows install zlib boost-system boost-program-options boost-test boost-align boost-foreach boost-python boost-math boost-thread python3 boost-python

Installing Vowpal Wabbit under an Anaconda environment (on OSX or Linux) can be done using the following steps:

$ git clone
# create conda environment if necessary
$ conda create -n vowpalwabbit
$ source activate vowpalwabbit
# install necessary boost dependencies
$ conda install -y -c anaconda boost
$ pip install -e vowpal_wabbit

For python3 on Ubuntu 16.04 LTS: Ubuntu 16.04 defaults to an old, custom-built version of boost. As such, the boost_python library names do not follow the standard naming convention adopted by offical boost releases for the boost_python libraries. You may need to manually create the relevant symlinks in this case. Example commands for python 3.5 follows:

$ cd /usr/lib/x86_64-linux-gnu/
$ sudo ln -s
$ sudo ln -s libboost_python-py35.a libboost_python3.a


Contributions are welcome for improving the python wrapper to Vowpal Wabbit.

  1. Check for open issues or create one to discuss a feature idea or bug.
  2. Fork the repo on Github and make changes to the master branch (or a new branch off of master).
  3. Write a test in the python/tests folder showing the bug was fixed or feature works (recommend using pytest).
  4. Make sure package installs and tests pass under all supported environments (this calls tox automatically).
  5. Send the pull request.

Tests can be run using

$ python test

Directory Structure:

  • python : this is where the c++ extension lives
  • python/vowpalwabbit : this is then main directory for python wrapper code and utilities
  • python/examples : example python code and jupyter notebooks to demonstrate functionality
  • python/tests : contains all tests for python code

Note: neither examples nor tests directories are included in the distributed package, they are only for development purposes.

Experimental build for Windows

An extension on the experimental Windows CMake build for the main project.

Note: attempting to install boost-python in vcpkg while multiple python versions are installed in vcpkg will cause errors. Ensure only the relevant python version is installed in the environment before proceeding.


  1. install required vcpkgs
> vcpkg install python3:x64-windows
> vcpkg install boost-python:x64-windows
  1. Run
> python --vcpkg-root=path\to\vcpkg install


Due to limitations in the current version of boost-python, some manual changes must be made to the vcpkg tools

  1. Edit [vcpkg-root]\ports\boost-python
  2. Edit the file CONTROL
    1. Change the Build-Depends entry for python3 to python2
  3. install required vcpkgs
> vcpkg install python2:x64-windows
> vcpkg install boost-python:x64-windows
  1. Run
> python --vcpkg-root=path\to\vcpkg install

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for vowpalwabbit, version 8.8.1
Filename, size File type Python version Upload date Hashes
Filename, size vowpalwabbit-8.8.1-cp36-cp36m-win_amd64.whl (3.0 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size vowpalwabbit-8.8.1-cp37-cp37m-win_amd64.whl (3.0 MB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size vowpalwabbit-8.8.1.tar.gz (3.1 MB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page