28

When using pip install Twisted in virtualenv on Mac osx 10.9.4, I get this result:

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/9r/3b500gbs3093ms87mqqbckr80000gn/T/pip-build-doynftp7/twisted/

I am not sure how to resolve. I used easy_install, but I get a SSL verification issue. Anyone have similar issue? The rest of error message is below.

 Collecting twisted
 Using cached Twisted-16.6.0.tar.bz2
 Complete output from command python setup.py egg_info:
Download error on https://pypi.python.org/simple/incremental/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) -- Some packages may not be found!
Couldn't find index page for 'incremental' (maybe misspelled?)
Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749) -- Some packages may not be found!
No local packages or working download links found for incremental>=16.10.1
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/folders/9r/3b500gbs3093ms87mqqbckr80000gn/T/pip-build-lqvxc68n/twisted/setup.py", line 21, in <module>
    setuptools.setup(**_setup["getSetupArgs"]())
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/Users/Complex-Cauchy/1/lib/python3.6/site-packages/setuptools/dist.py", line 317, in __init__
    self.fetch_build_eggs(attrs['setup_requires'])
  File "/Users/Complex-Cauchy/1/lib/python3.6/site-packages/setuptools/dist.py", line 372, in fetch_build_eggs
    replace_conflicting=True,
  File "/Users/Complex-Cauchy/1/lib/python3.6/site-packages/pkg_resources/__init__.py", line 851, in resolve
    dist = best[req.key] = env.best_match(req, ws, installer)
  File "/Users/Complex-Cauchy/1/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1123, in best_match
    return self.obtain(req, installer)
  File "/Users/Complex-Cauchy/1/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1135, in obtain
    return installer(requirement)
  File "/Users/Complex-Cauchy/1/lib/python3.6/site-packages/setuptools/dist.py", line 440, in fetch_build_egg
    return cmd.easy_install(req)
  File "/Users/Complex-Cauchy/1/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 668, in easy_install
    raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('incremental>=16.10.1')
 ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/9r/3b500gbs3093ms87mqqbckr80000gn/T/pip-build-lqvxc68n/twisted/

Running openssl s_client -showcerts -connect pypi.python.org:443 returns the following:

 CONNECTED(00000003)
 depth=1 /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended     Validation Server CA
 verify error:num=20:unable to get local issuer certificate
 verify return:0
 ---
 Certificate chain
  0 s:/businessCategory=Private Organization/1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Delaware/serialNumber=3359300/street=16 Allen    Rd/postalCode=03894-4801/C=US/ST=NH/L=Wolfeboro/O=Python Software Foundation/CN=www.python.org
  i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended Validation Server CA
  -----BEGIN CERTIFICATE-----
  MIIIWjCCB0KgAwIBAgIQCXCW7BLw16II/CMOsOFe/jANBgkqhkiG9w0BAQsFADB1
  ..
 -----END CERTIFICATE-----
 1 s:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended Validation Server CA
 i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA
 -----BEGIN CERTIFICATE-----
MIIEtjCCA56gAwIBAgIQDHmpRLCMEZUgkmFf4msdgzANBgkqhkiG9w0BAQsFADBs
....
-----END CERTIFICATE-----
 Server certificate
 subject=/businessCategory=Private Organization/1.3.6.1.4.1.311.60.2.1.3=US/1.3.6.1.4.1.311.60.2.1.2=Delaware/serialNumber=3359300/street=16 Allen Rd/postalCode=03894-4801/C=US/ST=NH/L=Wolfeboro/O=Python Software Foundation/CN=www.python.org
issuer=/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended  Validation Server CA
---
No client certificate CA names sent
---
SSL handshake has read 3524 bytes and written 456 bytes
---
New, TLSv1/SSLv3, Cipher is AES128-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol  : TLSv1
Cipher    : AES128-SHA
Session-ID: BC7695FF86D2B82B20468A13E3F3E13AE23776B500E64665305EEBAF49BB54D1
Session-ID-ctx: 
Master-Key:8D25B34237A3C74E90317D87BA74A2AAF0E8C424FB2ADE3D72E5F234D5E043C4527641290B928B3A22 1BE7D44116CFB1
Key-Arg   : None
Start Time: 1487035770
Timeout   : 300 (sec)
Verify return code: 0 (ok)
Jean-Paul Calderone
  • 47,755
  • 6
  • 94
  • 122
Johnathan Mackney
  • 545
  • 2
  • 6
  • 13
  • 7
    Do not use `sudo` to install into a virtualenv. – Jean-Paul Calderone Feb 09 '17 at 19:48
  • [SSL: CERTIFICATE_VERIFY_FAILED] I usually get around this by downloading and installing from source. BUT did you try: `xcode-select --install Twisted` as they mention is required on Mac? https://twistedmatrix.com/trac/wiki/Downloads – Matt Jun 07 '17 at 14:04
  • Did you manage to get it working? And if so how? If none of the provided answers were the ones working for you please consider to write your own answer. See https://stackoverflow.com/help/self-answer – fabianegli Jun 10 '17 at 09:44
  • Does the problem persist? If not, please accept the answer solving your issue or create an answer with your own solution and accept that. – fabianegli Feb 19 '18 at 17:46

5 Answers5

45

I had the same issue on a Mac OSX 10.11.6 in a new virtualenv with a fresh install of Python3.6.1. In my case, I had old versions of the Twisted dependency incremental installed, which prevented the installation.

pip install --upgrade incremental
pip install Twisted

Note I: I was installing a whole array of packages from a requirements file where the same incremental version was specified. I really wonder why the upgrade of incremental helped and have no clue what actually went wrong. If someone can clarify, that would be great.

Note II: Installing incremental ahead of of Twisted seems to be necessary on fresh installs, too [Experienced when working with CentOS7].

Note III: The issue was communicated to the amazing Twisted community and once Twisted ticket #9457 is implemented and in the release this question and my answer should become obsolete.

fabianegli
  • 2,056
  • 1
  • 18
  • 35
3

The error you reported is incomplete. There are almost certainly more details above it in the pip output. It would help if edit them into your question.

A survey of similar questions:

Suggests that:

  • You're missing setuptools. Inside a virtualenv (you did activate your virtualenv, right?) this seems implausible.
  • You're missing part of the C toolchain - a compiler, some necessary headers, etc. Twisted includes C extensions so this seems possible. Do you have a C toolchain?
  • You're using an incompatible version of Python. What version of Python are you using?

But the additional certificate verification failure errors you've included suggest it's not caused by any of these. Instead, a dependency cannot be downloaded because pip can't do a TLS handshake with the PyPI server it needs to download the dependency from.

This could be caused by many different things. Can your system's browsers load https://pypi.python.org/? If not, perhaps there's something wrong system-wide: you might have outdated certificate authority certificates or there might be a man-in-the-middle attack taking place.

openssl s_client can sometimes be useful for debugging issues like these. Try:

openssl s_client -showcerts -connect pypi.python.org:443

This may give you more details about what's happening at the TLS layer. If openssl s_client also has trouble verifying the certificate, you know there's something wrong system-wide. If not, we can narrow it down to a pip or Python problem.

Community
  • 1
  • 1
Jean-Paul Calderone
  • 47,755
  • 6
  • 94
  • 122
  • Have set up tools, have xcode downloaded, I have ran on python 2.7 and 3.6. – Johnathan Mackney Feb 10 '17 at 04:02
  • Have tried openssl s_client -showcerts -connect pypi.python.org:443, please find update in listing. – Johnathan Mackney Feb 14 '17 at 15:52
  • Huh. I don't understand the "verify error:num=20:unable to get local issuer certificate" (which should fail verification) followed by a "Verify return code: 0 (ok)" (which indicates verification succeeded) - unless it has to do with Apple's specially customized distribution of OpenSSL. :/ I think this is an OS X / OpenSSL question so I've edited the tags in hope of drawing someone who has more of a clue. – Jean-Paul Calderone Feb 14 '17 at 18:32
  • You could also try `pip install --verbose --verbose --verbose ...` and examine/include the log, it may have more information. – Jean-Paul Calderone Feb 14 '17 at 20:22
0

FWIW I was getting the same bogus error trying to install twisted:

distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('incremental>=16.10.1')

In my case I had accidentally installed an ancient setuptools that was messing up pip. It came from a python setup.py install of a zfec 1.4.22 tarball.

I fixed this by removing that setuptools (rm -rf /usr/local/lib/python2.7/dist-packages/setuptools-0*). This allowed the pip install twisted to work and allowed me to specify a version (twisted==18.9.0). The old setuptools was also causing latest twisted 19 to be installed in some situations.

jamshid
  • 1,775
  • 17
  • 14
-1

Try upgrading pip packages.

sudo pip install --upgrade pip

and Twisted has two required dependencies:

Installing a C compiler Since installing Twisted from source involves compiling C code, on OS X or Windows you’ll need to install a C compiler before you can install Twisted.

Installing zope.interface When installing from source, before you can use Twisted, you’ll also need to install zope.interface, which you can download from the Twisted home page.

And install it with your steps or follow this link

Shivkumar kondi
  • 6,458
  • 9
  • 31
  • 58
-2

I had a similar problem when installing Twisted on my MacBook, after trying many different ways, I successfully install Twisted using conda.

You can try it, using either Anaconda or miniconda.

https://conda.io/docs/download.html

https://stackoverflow.com/a/20994790/1294704

wings
  • 791
  • 6
  • 21