Skip to content

Installation

Bitstream supports Python 2.7 and 3.6 to 3.9 on Linux, Windows and MacOS.

We recommend you to install bitstream with pip. If for some reason that doesn't work for you -- for example if you want to modify the software -- you can also install bitstream from sources.

Install with Pip

Check the following prerequisites

Pip

The pip package installer should be available

$ pip --version
pip 9.0.1 from /usr/local/lib/python3.6/dist-packages (python 3.6)

Otherwise follow these instructions.

NumPy

Bitstream depends on the NumPy package; install it if necessary:

$ pip install numpy
C compiler

You need a compiler which can work with pip and your version of Python. On Windows, for Python 2.7 you can install the Microsoft Visual C++ Compiler for Python 2.7. For Python 3, a recent Visual Studio compiler (2015 or later) should work; you may for example install Visual Studio Community.

then install bitstream:

$ pip install bitstream

Install from Sources

Download the Sources

First, download the sources with git and enter the project directory:

$ git clone https://github.com/boisgera/bitstream
$ cd bitstream

Alternatively, you can also download the project ZIP archive. For example:

$ wget https://github.com/boisgera/bitstream/archive/master.zip
$ unzip master.zip
$ cd bitstream-master

Required Tools

Building from sources requires everything you need for a pip-based install and more. Since bitstream is written in Cython, at the very least you need a Cython compiler. If you don't mind having a few extra packags installed, it's easier to install all developer dependencies with:

$ pip install -r requirements-dev.txt

Build and Install

Run the command:

$ python setup.py --cython install

If you want to do more than just build bitstream from sources -- for example run the tests, regenerate the documentation, etc. -- please refer to the Contributing section.

Troubleshooting

The command python setup.py install doesn't work

This is expected: this command needs C files to build bitstream, which is a Python C extension module, but these files are not present in the git repository. They have first to be generated by the Cython compiler from the .pyx and .pxd files with:

$ python setup.py --cython build

To "solve" this issue, you can make the --cython option implicit with a setup.cfg file that contains:

[global]
cython = 1