error

This error means that you have missing bz2 headers (probably because you’ve built python from sources without this option enabled), so you need to install them first (for Ubuntu/Debian):

1
$ sudo apt-get install libbz2-dev

Now we need to reconfigure your python and reinstall it once again (version 3.6.5 for example below)

1
2
3
4
5
$ tar -xvf Python-3.6.5.tar.xz
$ cd Python-3.6.5/
$ ./configure
$ make
$ sudo make install

Check whether it works properly now

1
$ python3.6 -c "import bz2"

should return without any errors. And make sure to recreate your virtual environment which will use new python executable

1
2
$ pipenv --python 3.6.5
$ pipenv install

You should be all set up now, continue the adventure!