21

I am setting up a virtualenv on a new server, and when I used pip on our requirements file, it kept dying on Twisted. I commented the Twisted line out, and everything else installed fine. At the command line, this is the output I see when I try to install Twisted (the same error I see when I run the entire requirements file once it gets to the Twisted line):

(foo)company@server:~$ pip install twisted
Collecting twisted
  Could not find a version that satisfies the requirement twisted (from versions: )
No matching distribution found for twisted

I can install Twisted fine from my dev machine and other servers, and on this server I seem to be able to install other packages fine.

Case and version do not matter. Same result if I use "twisted", "Twisted", "Twisted==15.2.1".

This is an EC2 instance running Ubuntu 14.04.02.

Rjak
  • 2,097
  • 4
  • 19
  • 24

2 Answers2

43

Ok after struggling with this for several hours, I figured out the problem.

Running pip install --verbose twisted helped with the diagnosis.

The error message is misleading. The problem is that I built a custom installation of Python 2.7.10 without having previously installed libbz2-dev. So the steps to fix this were:

  1. sudo apt-get install libbz2-dev
  2. cd /<untarred python source dir>
  3. ./configure --prefix=<my install path> --enable-ipv6
  4. make
  5. make install

With this done, I can now create virtual environments and pip install Twisted.

Elias Dorneles
  • 22,556
  • 11
  • 85
  • 107
Rjak
  • 2,097
  • 4
  • 19
  • 24
  • 2
    If you're too lazy for recompiling Python, there're archives in other formats in https://github.com/twisted/twisted/releases. – Andre Miras Jul 01 '15 at 15:57
  • 2
    Running ```pip install --verbose twisted``` may help, I've edited the answer, I hope it gets approved. – Andre Miras Jul 01 '15 at 16:01
  • 1
    The trick for me was that libbz2-dev, then rebuild python. If you're using linuxbrew (which you should be, it's sweet), I did the `pip install --verbose twisted` then `brew reinstall python` and it worked. – Travis Reeder Feb 10 '16 at 04:42
  • 1
    Thanks for this! Have been struggling the entire day. Did the exact same thing as you did. Tried to install Twisted globally with the python distro coming with 12.04 which worked just fine but nothing I built myself. Guess the standard binaries were compiled in another context huh? – Gesias Feb 10 '17 at 15:52
  • 3
    For those who are using CentOS, Fedora or RHEL, the equivalent library that you need before compiling python is: `bzip2-devel`. The `libbz2-dev` only exists in Debian/Ubuntu. – RicLeal May 23 '17 at 14:25
3

I run into this issue when I tried install requirements on python 2.7.16. I've chosen to install package directly from zip archive Twisted releases
pip install https://github.com/twisted/twisted/archive/twisted-18.7.0.zip - it works for me

akpp
  • 706
  • 10
  • 12