5

I am trying to upload a new python project from my mac to PyPI via:

python setup.py sdist upload -r pypi

When I try to upload a package, I get the following error on OSX:

Submitting dist/PyTreasuryDirect-0.1.0.tar.gz to https://pypi.python.org/pypi
error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>

This question is slightly related to these two questions, ssl with pip and when importing the ssl library. However I need setup.py to work in my case, how can I get past this ssl error?

I also get the same error on Python 2.7.9 and Python 3.5 using OSX 10.10.2 (14C109)

Community
  • 1
  • 1
pyCthon
  • 11,746
  • 20
  • 73
  • 135
  • MacOSX 10.9+ switched from OpenSSL to SecureTransport for the SSL module. This is a major change in the way tools handle self-signed or unknown signed certificates. (e.g. this impacts [curl][1] for example) Is it possible you have an SSL proxy in the middle, and it does not like the self signed cert of the MitM proxy? [1]: http://curl.haxx.se/mail/archive-2013-10/0036.html – cgseller Apr 24 '15 at 15:13
  • @cgseller I think its a problem with how `setup.py` is handling ssl and I'm not sure how to fix it. I can get ssl to work on my mac via the other soltuion's but that invovles `pip` or the `openssl` package. – pyCthon Apr 24 '15 at 15:16
  • 1
    On OS X 10.10 with python 2.7.6 no such problem. You might be affected by [this issue](http://bugs.python.org/issue23052): "Python 2.7.9 enabled certificate validation by default for HTTP connections, see PEP476." – baf Apr 24 '15 at 16:04
  • @baf make this an answer, I simply had to use the default python from /usr/bin/python and not the macports or anaconda or hombrew version..... – pyCthon Apr 24 '15 at 16:37

1 Answers1

1

The solution for OS X 10.10 is to use its default Python version 2.7.6.

This problem is related to the fact that starting from Python version 2.7.9 certificate validation for stdlib http clients is enabled by default (PEP 476). This issue is described in Python bug tracker.

Elias Zamaria
  • 96,623
  • 33
  • 114
  • 148
baf
  • 4,531
  • 1
  • 21
  • 24
  • 2
    That's not at all a solution. Various setup.py scripts simply don't run on Python 2.7, so what should they do? – pedjjj Feb 17 '17 at 09:52