}

Python Pip: No matching distribution found for Twisted/Pillow

Created:

The error

When you try to install Twisted, Pillow or similar you could get the following error:

pip install Twisted
Collecting Twisted
  Could not find a version that satisfies the requirement Twisted (from versions: )
No matching distribution found for Twisted

The cause is that you python could be missing the bz2 extension, you can check it by importing bz2:

import bz2

If you have this error:

ython 3.6.2 (default, Aug  4 2018, 19:03:51)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bz2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/bz2.py", line 23, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
>>>

It means that you python is missing bz2, if the package uses bz2 compression pip will not install the package and it will say it is missing!.

Solution

If you compile python by yourself or you are using pyenv, you need to install the following dependencies:

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev

After you installed all of them, you need to recompile python.